This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- @desc: The fastest, type-agnostic way to copy a Redis key | |
| -- @usage: redis-cli --eval copy_key.lua <source> <dest> , [NX] | |
| local s = KEYS[1] | |
| local d = KEYS[2] | |
| if redis.call("EXISTS", d) == 1 then | |
| if type(ARGV[1]) == "string" and ARGV[1]:upper() == "NX" then | |
| return nil | |
| else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rld.start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 Threads | |
| 50 Connections per thread | |
| 1000000 Requests per thread | |
| Type Ops/sec Hits/sec Misses/sec Latency KB/sec | |
| ------------------------------------------------------------------------ | |
| Sets 198412.70 --- --- 9.04900 28440.00 | |
| Gets 198412.70 198412.70 0.00 9.01200 27471.00 | |
| Totals 396825.40 198412.70 0.00 9.03000 22623.00 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Follow these steps to deploy WordPress, Memcached Cloud and the Memcached Cloud Plugin for Wordpress on Heroku. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <!-- | |
| Red is Beautiful: A Visualization of Redis Commands | |
| By Itamar Haber, Redis Labs | |
| Adopted from Mike Bostock's Zoomable Pack Layout example: http://mbostock.github.io/d3/talk/20111116/pack-hierarchy.html | |
| !--> | |
| <html> | |
| <head> | |
| <style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| redis.call("zadd", KEYS[1], 1, ARGV[1]:reverse()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local res = redis.call("zrangebylex", KEYS[1], "\[" .. ARGV[1]:reverse(), "\[" .. ARGV[1]:reverse() .. "\\xff") | |
| for k, v in pairs(res) do | |
| res[k] = v:reverse() | |
| end | |
| return res |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ $# -ne 3 ] | |
| then | |
| echo "Delete keys from Redis matching a pattern using SCAN & DEL" | |
| echo "Usage: $0 <host> <port> <pattern>" | |
| exit 1 | |
| fi | |
| cursor=-1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import redis | |
| import re | |
| idle_max = 300 | |
| r = redis.Redis(host="localhost", port=6379, password=None) | |
| l = r.execute_command("client", "list") | |
| pattern = r"addr=(.*?) .*? idle=(\d*)" | |
| regex = re.compile(pattern) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local l = redis.call('client', 'list') | |
| local k = 0 | |
| for r in l:gmatch('[^\n]+') do | |
| for c,i in r:gmatch('addr=(.+:%d+).*idle=(%d+).*') do | |
| if tonumber(i) > tonumber(ARGV[1]) then | |
| redis.call('client', 'kill', c) | |
| k = k + 1 | |
| end | |
| end |