mirror of https://github.com/ledisdb/ledisdb.git
update lua
This commit is contained in:
parent
0af4758e79
commit
d917eeacd0
|
@ -10,6 +10,7 @@ LedisDB now supports multiple databases as backend to store data, you can test a
|
||||||
+ Stores lots of data, over the memory limit.
|
+ Stores lots of data, over the memory limit.
|
||||||
+ Various backend database to use: LevelDB, goleveldb, LMDB, RocksDB, BoltDB, HyperLevelDB.
|
+ Various backend database to use: LevelDB, goleveldb, LMDB, RocksDB, BoltDB, HyperLevelDB.
|
||||||
+ Supports transaction using LMDB or BotlDB.
|
+ Supports transaction using LMDB or BotlDB.
|
||||||
|
+ Supports lua scripting.
|
||||||
+ Supports expiration and ttl.
|
+ Supports expiration and ttl.
|
||||||
+ Redis clients, like redis-cli, are supported directly.
|
+ Redis clients, like redis-cli, are supported directly.
|
||||||
+ Multiple client API supports, including Go, Python, Lua(Openresty), C/C++, Node.js.
|
+ Multiple client API supports, including Go, Python, Lua(Openresty), C/C++, Node.js.
|
||||||
|
|
|
@ -905,6 +905,21 @@ class Ledis(object):
|
||||||
def bscan(self, key, match = "", count = 10):
|
def bscan(self, key, match = "", count = 10):
|
||||||
return self.execute_command("BSCAN", key, match, count)
|
return self.execute_command("BSCAN", key, match, count)
|
||||||
|
|
||||||
|
def eval(self, script, keys, *args):
|
||||||
|
return self.execute_command('EVAL', script, len(keys), *keys, *args)
|
||||||
|
|
||||||
|
def evalsha(self, sha1, keys, *args):
|
||||||
|
return self.execute_command('EVALSHA', sha1, len(keys), *keys, *args)
|
||||||
|
|
||||||
|
def scriptload(self, script):
|
||||||
|
return self.execute_command('SCRIPT LOAD', script)
|
||||||
|
|
||||||
|
def scriptexists(self, *args):
|
||||||
|
return self.execute_command('SCRIPT EXISTS', *args)
|
||||||
|
|
||||||
|
def scriptflush(self):
|
||||||
|
return self.execute_command('SCRIPT FLUSH')
|
||||||
|
|
||||||
class Transaction(Ledis):
|
class Transaction(Ledis):
|
||||||
def __init__(self, connection_pool, response_callbacks):
|
def __init__(self, connection_pool, response_callbacks):
|
||||||
self.connection_pool = connection_pool
|
self.connection_pool = connection_pool
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
# coding: utf-8
|
||||||
|
# Test Cases for bit commands
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import sys
|
||||||
|
sys.path.append('..')
|
||||||
|
|
||||||
|
import ledis
|
||||||
|
from ledis._compat import b
|
||||||
|
from util import expire_at, expire_at_seconds
|
||||||
|
|
||||||
|
l = ledis.Ledis(port=6380)
|
||||||
|
|
||||||
|
|
||||||
|
class TestCmdScript(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -129,4 +129,9 @@ module.exports = [
|
||||||
"rollback",
|
"rollback",
|
||||||
"commit",
|
"commit",
|
||||||
|
|
||||||
|
"eval",
|
||||||
|
"evalsha",
|
||||||
|
"script load",
|
||||||
|
"script exists",
|
||||||
|
"script flush",
|
||||||
];
|
];
|
||||||
|
|
|
@ -151,7 +151,14 @@ local commands = {
|
||||||
-- [[transaction]]
|
-- [[transaction]]
|
||||||
"begin",
|
"begin",
|
||||||
"commit",
|
"commit",
|
||||||
"rollback"
|
"rollback",
|
||||||
|
|
||||||
|
-- [[script]]
|
||||||
|
"eval",
|
||||||
|
"evalsha",
|
||||||
|
"script load",
|
||||||
|
"script exists",
|
||||||
|
"script flush"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//This file was generated by .tools/generate_commands.py on Wed Aug 27 2014 11:14:50 +0800
|
//This file was generated by .tools/generate_commands.py on Tue Sep 02 2014 22:27:45 +0800
|
||||||
package main
|
package main
|
||||||
|
|
||||||
var helpCommands = [][]string{
|
var helpCommands = [][]string{
|
||||||
|
@ -20,6 +20,8 @@ var helpCommands = [][]string{
|
||||||
{"DECRBY", "key decrement", "KV"},
|
{"DECRBY", "key decrement", "KV"},
|
||||||
{"DEL", "key [key ...]", "KV"},
|
{"DEL", "key [key ...]", "KV"},
|
||||||
{"ECHO", "message", "Server"},
|
{"ECHO", "message", "Server"},
|
||||||
|
{"EVAL", "script numkeys key [key ...] arg [arg ...]", "Script"},
|
||||||
|
{"EVALSHA", "sha1 numkeys key [key ...] arg [arg ...]", "Script"},
|
||||||
{"EXISTS", "key", "KV"},
|
{"EXISTS", "key", "KV"},
|
||||||
{"EXPIRE", "key seconds", "KV"},
|
{"EXPIRE", "key seconds", "KV"},
|
||||||
{"EXPIREAT", "key timestamp", "KV"},
|
{"EXPIREAT", "key timestamp", "KV"},
|
||||||
|
@ -72,6 +74,9 @@ var helpCommands = [][]string{
|
||||||
{"SCAN", "key [MATCH match] [COUNT count]", "KV"},
|
{"SCAN", "key [MATCH match] [COUNT count]", "KV"},
|
||||||
{"SCARD", "key", "Set"},
|
{"SCARD", "key", "Set"},
|
||||||
{"SCLEAR", "key", "Set"},
|
{"SCLEAR", "key", "Set"},
|
||||||
|
{"SCRIPT EXISTS", "script [script ...]", "Script"},
|
||||||
|
{"SCRIPT FLUSH", "-", "Script"},
|
||||||
|
{"SCRIPT LOAD", "script", "Script"},
|
||||||
{"SDIFF", "key [key ...]", "Set"},
|
{"SDIFF", "key [key ...]", "Set"},
|
||||||
{"SDIFFSTORE", "destination key [key ...]", "Set"},
|
{"SDIFFSTORE", "destination key [key ...]", "Set"},
|
||||||
{"SELECT", "index", "Server"},
|
{"SELECT", "index", "Server"},
|
||||||
|
|
|
@ -580,5 +580,36 @@
|
||||||
"arguments": "[section]",
|
"arguments": "[section]",
|
||||||
"group": "Server",
|
"group": "Server",
|
||||||
"readonly": true
|
"readonly": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"EVAL": {
|
||||||
|
"arguments": "script numkeys key [key ...] arg [arg ...]",
|
||||||
|
"group": "Script",
|
||||||
|
"readonly": false
|
||||||
|
},
|
||||||
|
|
||||||
|
"EVALSHA": {
|
||||||
|
"arguments": "sha1 numkeys key [key ...] arg [arg ...]",
|
||||||
|
"group": "Script",
|
||||||
|
"readonly": false
|
||||||
|
},
|
||||||
|
|
||||||
|
"SCRIPT LOAD": {
|
||||||
|
"arguments": "script",
|
||||||
|
"group": "Script",
|
||||||
|
"readonly": false
|
||||||
|
},
|
||||||
|
|
||||||
|
"SCRIPT EXISTS": {
|
||||||
|
"arguments": "script [script ...]",
|
||||||
|
"group": "Script",
|
||||||
|
"readonly": false
|
||||||
|
},
|
||||||
|
|
||||||
|
"SCRIPT FLUSH": {
|
||||||
|
"arguments" : "-",
|
||||||
|
"group": "Script",
|
||||||
|
"readonly": false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ Table of Contents
|
||||||
- [SINTERSTORE destination key [key ...]](#sinterstore-destination-key-key-)
|
- [SINTERSTORE destination key [key ...]](#sinterstore-destination-key-key-)
|
||||||
- [SISMEMBER key member](#sismember-key-member)
|
- [SISMEMBER key member](#sismember-key-member)
|
||||||
- [SMEMBERS key](#smembers-key)
|
- [SMEMBERS key](#smembers-key)
|
||||||
- [SREM key member [member]](#srem-key-member-member-)
|
- [SREM key member [member ...]](#srem-key-member-member-)
|
||||||
- [SUNION key [key ...]](#sunion-key-key-)
|
- [SUNION key [key ...]](#sunion-key-key-)
|
||||||
- [SUNIONSTORE destination key [key ...]](#sunionstore-destination-key-key-)
|
- [SUNIONSTORE destination key [key ...]](#sunionstore-destination-key-key-)
|
||||||
- [SCLEAR key](#sclear-key)
|
- [SCLEAR key](#sclear-key)
|
||||||
|
@ -133,7 +133,12 @@ Table of Contents
|
||||||
- [BEGIN](#begin)
|
- [BEGIN](#begin)
|
||||||
- [ROLLBACK](#rollback)
|
- [ROLLBACK](#rollback)
|
||||||
- [COMMIT](#commit)
|
- [COMMIT](#commit)
|
||||||
|
- [Script](#script)
|
||||||
|
- [EVAL script numkeys key [key ...] arg [arg ...]](#eval-script-numkeys-key-key--arg-arg-)
|
||||||
|
- [EVALSHA sha1 numkeys key [key ...] arg [arg ...]](#evalsha-sha1-numkeys-key-key--arg-arg-)
|
||||||
|
- [SCRIPT LOAD script](#script-load-script)
|
||||||
|
- [SCRIPT EXISTS script [script ...]](#script-exists-script-script-)
|
||||||
|
- [SCRIPT FLUSH](#script-flush)
|
||||||
|
|
||||||
## KV
|
## KV
|
||||||
|
|
||||||
|
@ -2562,4 +2567,21 @@ ledis> GET HELLO
|
||||||
"WORLD"
|
"WORLD"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Script
|
||||||
|
|
||||||
|
LedisDB's script is refer to Redis, you can see more [http://redis.io/commands/eval](http://redis.io/commands/eval)
|
||||||
|
|
||||||
|
You must notice that executing lua will block any other write operations.
|
||||||
|
|
||||||
|
### EVAL script numkeys key [key ...] arg [arg ...]
|
||||||
|
|
||||||
|
### EVALSHA sha1 numkeys key [key ...] arg [arg ...]
|
||||||
|
|
||||||
|
### SCRIPT LOAD script
|
||||||
|
|
||||||
|
### SCRIPT EXISTS script [script ...]
|
||||||
|
|
||||||
|
### SCRIPT FLUSH
|
||||||
|
|
||||||
|
|
||||||
Thanks [doctoc](http://doctoc.herokuapp.com/)
|
Thanks [doctoc](http://doctoc.herokuapp.com/)
|
||||||
|
|
Loading…
Reference in New Issue