mirror of https://github.com/ledisdb/ledisdb.git
parent
fa6adeabee
commit
5f5b7f1ac7
|
@ -219,6 +219,16 @@ class Ledis(object):
|
|||
db = 0
|
||||
return self.execute_command('SELECT', db)
|
||||
|
||||
def info(self, section):
|
||||
return self.execute_command('PING', section)
|
||||
|
||||
def flushall(self):
|
||||
return self.execute_command('FLUSHALL')
|
||||
|
||||
def flushdb(self):
|
||||
return self.execute_command('FLUSHDB')
|
||||
|
||||
|
||||
#### BASIC KEY COMMANDS ####
|
||||
def decr(self, name, amount=1):
|
||||
"""
|
||||
|
@ -340,6 +350,9 @@ class Ledis(object):
|
|||
"Removes an expiration on name"
|
||||
return self.execute_command('PERSIST', name)
|
||||
|
||||
def scan(self, key, match = "", count = 10):
|
||||
return self.execute_command("SCAN", key, match, count)
|
||||
|
||||
#### LIST COMMANDS ####
|
||||
def lindex(self, name, index):
|
||||
"""
|
||||
|
@ -415,6 +428,9 @@ class Ledis(object):
|
|||
"Removes an expiration on ``name``"
|
||||
return self.execute_command('LPERSIST', name)
|
||||
|
||||
def lscan(self, key, match = "", count = 10):
|
||||
return self.execute_command("LSCAN", key, match, count)
|
||||
|
||||
|
||||
#### SET COMMANDS ####
|
||||
def sadd(self, name, *values):
|
||||
|
@ -512,6 +528,9 @@ class Ledis(object):
|
|||
"Removes an expiration on name"
|
||||
return self.execute_command('SPERSIST', name)
|
||||
|
||||
def sscan(self, key, match = "", count = 10):
|
||||
return self.execute_command("SSCAN", key, match, count)
|
||||
|
||||
|
||||
#### SORTED SET COMMANDS ####
|
||||
def zadd(self, name, *args, **kwargs):
|
||||
|
@ -708,6 +727,8 @@ class Ledis(object):
|
|||
"Removes an expiration on name"
|
||||
return self.execute_command('ZPERSIST', name)
|
||||
|
||||
def zscan(self, key, match = "", count = 10):
|
||||
return self.execute_command("ZSCAN", key, match, count)
|
||||
|
||||
|
||||
#### HASH COMMANDS ####
|
||||
|
@ -802,6 +823,9 @@ class Ledis(object):
|
|||
"Removes an expiration on name"
|
||||
return self.execute_command('HPERSIST', name)
|
||||
|
||||
def hscan(self, key, match = "", count = 10):
|
||||
return self.execute_command("HSCAN", key, match, count)
|
||||
|
||||
|
||||
### BIT COMMANDS
|
||||
def bget(self, name):
|
||||
|
@ -878,6 +902,8 @@ class Ledis(object):
|
|||
"Removes an expiration on name"
|
||||
return self.execute_command('BPERSIST', name)
|
||||
|
||||
def bscan(self, key, match = "", count = 10):
|
||||
return self.execute_command("BSCAN", key, match, count)
|
||||
|
||||
class Transaction(Ledis):
|
||||
def __init__(self, connection_pool, response_callbacks):
|
||||
|
|
|
@ -5,6 +5,9 @@ module.exports = [
|
|||
"ping",
|
||||
"echo",
|
||||
"select",
|
||||
"info",
|
||||
"flushall",
|
||||
"flushdb",
|
||||
|
||||
"bget",
|
||||
"bdelete",
|
||||
|
@ -17,7 +20,7 @@ module.exports = [
|
|||
"bexpireat",
|
||||
"bttl",
|
||||
"bpersist",
|
||||
|
||||
"bscan",
|
||||
|
||||
"hdel",
|
||||
"hexists",
|
||||
|
@ -31,14 +34,13 @@ module.exports = [
|
|||
"hset",
|
||||
"hvals",
|
||||
|
||||
|
||||
"hclear",
|
||||
"hmclear",
|
||||
"hexpire",
|
||||
"hexpireat",
|
||||
"httl",
|
||||
"hpersist",
|
||||
|
||||
"hscan",
|
||||
|
||||
"decr",
|
||||
"decrby",
|
||||
|
@ -56,6 +58,7 @@ module.exports = [
|
|||
"expireat",
|
||||
"ttl",
|
||||
"persist",
|
||||
"scan",
|
||||
|
||||
"lindex",
|
||||
"llen",
|
||||
|
@ -72,6 +75,7 @@ module.exports = [
|
|||
"lexpireat",
|
||||
"lttl",
|
||||
"lpersist",
|
||||
"lscan",
|
||||
|
||||
"zadd",
|
||||
"zcard",
|
||||
|
@ -97,6 +101,7 @@ module.exports = [
|
|||
"zexpireat",
|
||||
"zttl",
|
||||
"zpersist",
|
||||
"zscan",
|
||||
|
||||
|
||||
"sadd",
|
||||
|
@ -118,6 +123,7 @@ module.exports = [
|
|||
"sexpireat",
|
||||
"sttl",
|
||||
"spersist",
|
||||
"sscan",
|
||||
|
||||
"begin",
|
||||
"rollback",
|
||||
|
|
|
@ -40,6 +40,7 @@ local commands = {
|
|||
"expire",
|
||||
"expireat",
|
||||
"persist",
|
||||
"scan",
|
||||
|
||||
--[[hash]]
|
||||
"hdel",
|
||||
|
@ -60,6 +61,7 @@ local commands = {
|
|||
"hexpireat",
|
||||
"httl",
|
||||
"hpersist",
|
||||
"hscan",
|
||||
|
||||
--[[list]]
|
||||
"lindex",
|
||||
|
@ -76,6 +78,7 @@ local commands = {
|
|||
"lexpireat",
|
||||
"lttl",
|
||||
"lpersist",
|
||||
"lscan",
|
||||
|
||||
--[[zset]]
|
||||
"zadd",
|
||||
|
@ -99,6 +102,7 @@ local commands = {
|
|||
"zexpireat",
|
||||
"zttl",
|
||||
"zpersist",
|
||||
"zscan",
|
||||
|
||||
--[[bit]]
|
||||
"bget",
|
||||
|
@ -112,6 +116,7 @@ local commands = {
|
|||
"bexpireat",
|
||||
"bttl",
|
||||
"bpersist",
|
||||
"bscan",
|
||||
|
||||
--[[set]]
|
||||
"sadd",
|
||||
|
@ -133,11 +138,15 @@ local commands = {
|
|||
"sexpireat",
|
||||
"sttl",
|
||||
"spersist",
|
||||
"sscan",
|
||||
|
||||
--[[server]]
|
||||
"ping",
|
||||
"echo",
|
||||
"select",
|
||||
"info",
|
||||
"flushall",
|
||||
"flushdb",
|
||||
|
||||
-- [[transaction]]
|
||||
"begin",
|
||||
|
|
|
@ -531,36 +531,54 @@
|
|||
"SCAN": {
|
||||
"arguments": "key [MATCH match] [COUNT count]",
|
||||
"group": "KV",
|
||||
"readonly": false
|
||||
"readonly": true
|
||||
},
|
||||
|
||||
"HSCAN": {
|
||||
"arguments": "key [MATCH match] [COUNT count]",
|
||||
"group": "Hash",
|
||||
"readonly": false
|
||||
"readonly": true
|
||||
},
|
||||
|
||||
"LSCAN": {
|
||||
"arguments": "key [MATCH match] [COUNT count]",
|
||||
"group": "List",
|
||||
"readonly": false
|
||||
"readonly": true
|
||||
},
|
||||
|
||||
"SSCAN": {
|
||||
"arguments": "key [MATCH match] [COUNT count]",
|
||||
"group": "Set",
|
||||
"readonly": false
|
||||
"readonly": true
|
||||
},
|
||||
|
||||
"ZSCAN": {
|
||||
"arguments": "key [MATCH match] [COUNT count]",
|
||||
"group": "ZSet",
|
||||
"readonly": false
|
||||
"readonly": true
|
||||
},
|
||||
|
||||
"BSCAN": {
|
||||
"arguments": "key [MATCH match] [COUNT count]",
|
||||
"group": "Bitmap",
|
||||
"readonly": true
|
||||
},
|
||||
|
||||
"FLUSHALL": {
|
||||
"arguments": "-",
|
||||
"group": "Server",
|
||||
"readonly": false
|
||||
},
|
||||
|
||||
"FLUSHDB": {
|
||||
"arguments": "-",
|
||||
"group": "Server",
|
||||
"readonly": false
|
||||
},
|
||||
|
||||
"INFO": {
|
||||
"arguments": "[section]",
|
||||
"group": "Server",
|
||||
"readonly": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,6 +126,9 @@ Table of Contents
|
|||
- [PING](#ping)
|
||||
- [ECHO message](#echo-message)
|
||||
- [SELECT index](#select-index)
|
||||
- [FLUSHALL](#flushall)
|
||||
- [FLUSHDB](#flushdb)
|
||||
- [INFO [section]](#info-section)
|
||||
- [Transaction](#transaction)
|
||||
- [BEGIN](#begin)
|
||||
- [ROLLBACK](#rollback)
|
||||
|
@ -2468,6 +2471,33 @@ ledis> SELECT 16
|
|||
ERR invalid db index 16
|
||||
```
|
||||
|
||||
### FLUSHALL
|
||||
|
||||
Delete all the keys of all the existing databases, not just the currently selected one. This command never fails.
|
||||
|
||||
Very dangerous to use!!!
|
||||
|
||||
### FLUSHDB
|
||||
|
||||
Delete all the keys of the currently selected DB. This command never fails.
|
||||
|
||||
Very dangerous to use!!!
|
||||
|
||||
### INFO [section]
|
||||
|
||||
Return information and statistic about the server in a format that is simple to parse by computers and easy to read by humans.
|
||||
|
||||
The optional parameter can be used to select a specific section of information:
|
||||
|
||||
+ server: General information about the Redis server
|
||||
+ client: Client connections section
|
||||
+ mem: Memory consumption related information
|
||||
+ cpu: CPU consumption statistics
|
||||
+ goroutine: Goroutine num
|
||||
+ persistence: Strorage related information
|
||||
|
||||
When no parameter is provided, all will return.
|
||||
|
||||
## Transaction
|
||||
|
||||
### BEGIN
|
||||
|
|
|
@ -14,6 +14,8 @@ var txUnsupportedCmds = map[string]struct{}{
|
|||
"fullsync": struct{}{},
|
||||
"sync": struct{}{},
|
||||
"begin": struct{}{},
|
||||
"flushall": struct{}{},
|
||||
"flushdb": struct{}{},
|
||||
}
|
||||
|
||||
type responseWriter interface {
|
||||
|
|
|
@ -67,10 +67,31 @@ func infoCommand(c *client) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
func flushallCommand(c *client) error {
|
||||
err := c.ldb.FlushAll()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.resp.writeStatus(OK)
|
||||
return nil
|
||||
}
|
||||
|
||||
func flushdbCommand(c *client) error {
|
||||
_, err := c.db.FlushAll()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.resp.writeStatus(OK)
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
register("ping", pingCommand)
|
||||
register("echo", echoCommand)
|
||||
register("select", selectCommand)
|
||||
register("info", infoCommand)
|
||||
register("flushall", flushallCommand)
|
||||
register("flushdb", flushdbCommand)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue