-
Notifications
You must be signed in to change notification settings - Fork 1
/
redis.el
executable file
·148 lines (143 loc) · 10.8 KB
/
redis.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
(setq redis-commands
(list
(list "close the connection" "quit")
(list "simple password authentication if enabled" "auth")
(list "test if a key exists" "exists" "key")
(list "delete a key" "del" "key")
(list "return the type of the value stored at key" "type" "key")
(list "return all the keys matching a given pattern" "keys" "pattern")
(list "return a random key from the key space" "randomkey")
(list "rename the old key in the new onedestroing the newname key if it already exists" "rename" "oldname " "newname")
(list "rename the old key in the new one if the newname key does not already exist" "renamenx" "oldname " "newname")
(list "return the number of keys in the current db" "dbsize")
(list "set a time to live in seconds on a key" "expire")
(list "get the time to live in seconds of a key" "ttl")
(list "select the db having the specified index" "select" "index")
(list "move the key from the currently selected db to the db having as index dbindex" "move" "key" "dbindex")
(list "remove all the keys of the currently selected db" "flushdb")
(list "remove all the keys from all the databases" "flushall")
(list "set a key to a string value" "set" "key" "value")
(list "return the string value of the key" "get" "key")
(list "set a key to a string returning the old value of the key" "getset" "key" "value")
(list "multi-get return the strings values of the keys" "mget" "key1" "key2" "keyn")
(list "set a key to a string value if the key does not exist" "setnx" "key" "value")
(list "set+expire combo command" "setex" "key" "time" "value")
(list "set a multiple keys to multiple values in a single atomic operation" "mset" "key1" "value1" "key2" "value2" "keyn" "valuen")
(list "set a multiple keys to multiple values in a single atomic operation if none of the keys already exist" "msetnx" "key1" "value1" "key2" "value2" "keyn" "valuen")
(list "increment the integer value of key" "incr" "key")
(list "increment the integer value of key by integer" "incrby" "key" "integer")
(list "decrement the integer value of key" "decr" "key")
(list "decrement the integer value of key by integer" "decrby" "key" "integer")
(list "append the specified string to the string stored at key" "append" "key" "value")
(list "return a substring out of a larger string" "substr" "key" "start" "end")
(list "Append an element to the tail of the List value at key" "rpush" "key" "value")
(list "Append an element to the head of the List value at key" "lpush" "key" "value")
(list "Return the length of the List value at key" "llen" "key")
(list "Return a range of elements from the List at key" "lrange" "key" "start" "end")
(list "Trim the list at key to the specified range of elements" "ltrim" "key" "start" "end")
(list "Return the element at index position from the List at key" "lindex" "key" "index")
(list "Set a new value as the element at index position of the List at key" "lset" "key" "index" "value")
(list "Remove the first-N last-N or all the elements matching value from the List at key" "lrem" "key" "count" "value")
(list "Return and remove (atomically) the first element of the List at key" "lpop" "key")
(list "Return and remove (atomically) the last element of the List at key" "rpop" "key")
(list "Blocking LPOP" "blpop" "key1" "key2" "keyn" "timeout")
(list "Blocking RPOP" "brpop" "key1" "key2" "keyn" "timeout")
(list "Return and remove (atomically) the last element of the source List stored at _srckey_ and push the same element to the destination List stored at _dstkey_" "rpoplpush" "srckey" "dstkey")
(list "Add the specified member to the Set value at key" "sadd" "key" "member")
(list "Remove the specified member from the Set value at key" "srem" "key" "member")
(list "Remove and return (pop) a random element from the Set value at key" "spop" "key")
(list "Move the specified member from one Set to another atomically" "smove" "srckey" "dstkey" "member")
(list "Return the number of elements (the cardinality) of the Set at key" "scard" "key")
(list "Test if the specified value is a member of the Set at key" "sismember" "key" "member")
(list "Return the intersection between the Sets stored at key1 key2 ... keyN" "sinter" "key1" "key2" "keyn")
(list "Compute the intersection between the Sets stored at key1 key2 ... keyN and store the resulting Set at dstkey" "sinterstore" "dstkey" "key1" "key2" "keyn")
(list "Return the union between the Sets stored at key1 key2 ... keyN" "sunion" "key1" "key2" "keyn")
(list "Compute the union between the Sets stored at key1 key2 ... keyN and store the resulting Set at dstkey" "sunionstore" "dstkey" "key1" "key2" "keyn")
(list "Return the difference between the Set stored at key1 and all the Sets key2 ... keyN" "sdiff" "key1" "key2" "keyn")
(list "Compute the difference between the Set key1 and all the Sets key2 ... keyN and store the resulting Set at dstkey" "sdiffstore" "dstkey" "key1" "key2" "keyn")
(list "Return all the members of the Set value at key" "smembers" "key")
(list "Return a random member of the Set value at key" "srandmember" "key")
(list "Add the specified member to the Sorted Set value at key or update the score if it already exist" "zadd" "key" "score" "member")
(list "Remove the specified member from the Sorted Set value at key" "zrem" "key" "member")
(list "If the member already exists increment its score by _increment_ otherwise add the member setting _increment_ as score" "zincrby" "key" "increment" "member")
(list "Return the rank (or index) or _member_ in the sorted set at _key_ with scores being ordered from low to high" "zrank" "key" "member")
(list "Return the rank (or index) or _member_ in the sorted set at _key_ with scores being ordered from high to low" "zrevrank" "key" "member")
(list "Return a range of elements from the sorted set at key" "zrange" "key" "start" "end")
(list "Return a range of elements from the sorted set at key exactly like ZRANGE but the sorted" "zrevrange" "key" "start" "end")
(list "Return all the elements with score >= min and score <= max (a range query) from the sorted set" "zrangebyscore" "key" "min" "max")
(list "Return the cardinality (number of elements) of the sorted set at key" "zcard" "key")
(list "Return the score associated with the specified element of the sorted set at key" "zscore" "key" "element")
(list "Remove all the elements with rank >= min and rank <= max from the sorted set" "zremrangebyrank" "key" "min" "max")
(list "Remove all the elements with score >= min and score <= max from the sorted set" "zremrangebyscore" "key" "min" "max")
(list "Perform a union over a number of sorted sets with optional weight and aggregate on hashes" "zunionstore" "dstkey" "n" "key1" "keyn" "weights" "w1" "wn" "aggregate" "sum" "min" "max")
(list "Perform a intersection over a number of sorted sets with optional weight and aggregate" "zinterstore" "dstkey" "n" "key1" "keyn" "weights" "w1" "wn" "aggregate" "sum" "min" "max")
(list "Set the hash field to the specified value. Creates the hash if needed." "set" "key" "field" "value")
(list "Retrieve the value of the specified hash field." "get" "key" "field")
(list "set the specified hash field to th sepcified value, if field do not exist" "setnx" "key" "field" "value")
(list "Get the hash values assoicated to the specified fields." "mget" "key" "field1" "fieldn")
(list "Set the hash fields to their respective values." "mset" "key" "field1" "value1" "fieldn" "valuen")
(list "Increment the integer value of the hash at _key_ on _field_ with _integer_." "incrby" "key" "field" "integer")
(list "Test for existence of a specified field in a hash" "exists" "key" "field")
(list "Remove the specified field from a hash" "del" "key" "field")
(list "Return the number of items in a hash." "len" "key")
(list "Return all the fields in a hash." "keys" "key")
(list "Return all the values in a hash." "vals" "key")
(list "Return all the fields and associated values in a hash." "getall" "key")
(list "subscribe message" "subscribe" "channel1" "channel2" "channeln")
(list "unsubscribe message" "unsubscribe" "channel1" "channel2" "channeln")
(list "unsubscribe all message" "unsubscribe")
(list "patttern subsribe message" "psubscribe" "pattern1" "pattern2" "patternn")
(list "patttern unsubsribe message" "punsubscribe" "pattern1" "pattern2" "patternn")
(list "patttern unsubsribe all message" "punsubscribe" "pattern1" "pattern2" "patternn")
(list "publish message" "publish" "channel" "message")
(list "Synchronously save the DB on disk" "save")
(list "Asynchronously save the DB on disk" "bgsave")
(list "Return the UNIX time stamp of the last successfully saving of the dataset on disk" "lastsave")
(list "Synchronously save the DB on disk then shutdown the server" "shutdown")
(list "Rewrite the append only file in background when it gets too big" "bgrewriteaof")
(list "Provide information and statistics about the server" "info")
(list "Dump all the received requests in real time" "monitor")
(list "Change the replication settings" "slaveof" "host" "port")
(list "stop replication settings" "slaveof" "no" "one")
(list "Configure a Redis server at runtime" "config")
))
(defun yas/redis (l)
(let ((cmd (cdr l))
(desp (car l)))
(find-file (concat "~/etc/el/vendor/yasnippet/snippets/text-mode/redis-mode/" (car cmd)))
(with-current-buffer (car cmd)
(delete-region (point-min) (point-max))
(insert
(concat
"# name : " (car cmd) " " desp "\n"
"# (link \"~/local/src/redis/doc/" (capitalize (car cmd)) "Command.txt\" 1)\n"
"# --\n"
(car cmd)
" "
(let ((i 0))
(mapconcat
(lambda (p)
(setq i (+ 1 i))
(concat
"${" (number-to-string i) ":" p "}")
)
(cdr cmd) " "))))))
(save-buffer))
(defun redis ()
"begin redis client"
(interactive)
(unless (setq redis-process (get-buffer-process "*redis*"))
(progn
(make-comint "redis" "redis-cli")
(setq redis-process (get-buffer-process "*redis*"))
(with-current-buffer "*redis*"
(setq major-mode 'redis-mode)
)))
(pop-to-buffer "*redis*"))
(defun redis-mode ()
"Major mode for redis client "
(interactive)
(kill-all-local-variables)
(setq mode-name "Redis")
(run-hooks 'redis-mode-hook))
(provide 'redis)