The PHP script redis-import.php in tools/ directory is the script to copy data from a Redis instance to a SSDB instance.
Usage:
php redis-import.php redis_host redis_port redis_db ssdb_host ssdb_port
Options:
Make sure you have the PHP Redis module https://github.com/nicolasff/phpredis installed.
| Tool | Supported |
|---|---|
| redis-cli | Yes |
| Twemproxy | Yes |
| Sentinel | No |
SSDB supports Redis network protocol, you can use Redis clients to connect to a SSDB server and operate on it.
But if you want to use SSDB clients, you will need this Redis-To-SSDB commands transfrom table.
| Redis | SSDB |
|---|---|
| get | get |
| set | set |
| setex | setx(for kv type only) |
| del | del |
| incr/incrBy | incr |
| decr/decrBy | decr |
| mget/getMultiple | multi_get |
| setMultiple | multi_set |
| del(multiple) | multi_del |
| keys | keys(for kv type only) |
| getset | getset |
| setnx | setnx |
| exists | exists |
| ttl | ttl |
| expire | expire |
| getbit | getbit |
| setbit | setbit |
| bitcount | redis_bitcount, countbit |
| strlen | strlen |
| getrange | getrange |
Please read these notes very carefully:
substr command is deprecated in Redis, so you should never use substr with a Redis client(however, you CAN do this, but MUST not do this)getrange instead if you are sticking your mind with Redissubstr(start, size) and getrange(start, end)size is negative, the behavior may be strange for those who are not familiar with PHP languagesubstr in SSDB works as described here| Redis | SSDB |
|---|---|
| del(not supported) | hclear |
| hget | hget |
| hset | hset |
| hdel, hmdel | hdel, multi_hdel |
| hIncrBy | hincr |
| hDecrBy | hdecr |
| hKeys | hkeys |
| hVals | hscan |
| hMGet | multi_hget |
| hMSet | multi_hset |
| hLen | hsize |
| hExists | hexists |
| keys | hlist(for hash type only) |
If you want to delete a hash entirely, you have to use a SSDB client to execute hclear command. You cannot delete a hash with any Redis client.
| Redis | SSDB |
|---|---|
| del(not supported) | zclear |
| zScore | zget |
| zAdd | zset |
| zRem | zdel |
| zRange | zrange |
| zRevRange | zrrange |
| zRangeByScore | zscan |
| zRevRangeByScore | zrscan |
| zIncrBy | zincr |
| zDecrBy | zdecr |
| zCount | zcount |
| zSum | zsum |
| zAvg | zavg |
| zCard | zsize |
| zRank | zrank |
| zRemRangeByRank | zremrangebyrank |
| zRemRangeByScore | zremrangebyscore |
| keys | zlist(for zset type only) |
If you want to delete a zset entirely, you have to use a SSDB client to execute zclear command. You cannot delete a zset with any Redis client.
| Redis | SSDB |
|---|---|
| del(not supported) | qclear |
| llen/lsize | qsize |
| lpush | qpush_front |
| rpush | qpush_back |
| lpop | qpop_front |
| rpop | qpop_back |
| lrange | qslice |
| lindex, lget | qget |
| lset | qset |
| keys | qlist(for queue/list type only) |
If you want to delete a list entirely, you have to use a SSDB client to execute qclear command. You cannot delete a list with any Redis client.