Migrate from Redis to SSDB
Tools
The redis-import.php
PHP script in the tools
directory can be used to Data on the Redis server is copied to the SSDB server.
Usage:
php redis-import.php redis_host redis_port redis_db ssdb_host ssdb_port
Parameters:
- redis_host: the IP or host name where Redis runs
- redis_port: the port Redis listens on
- redis_db: the DB number of Redis
- ssdb_host: the IP or host name where SSDB runs
- ssdb_port: SSDB listening port
Please make sure your PHP Redis module https://github.com/nicolasff/phpredis has been installed.
Redis Tool Support
Tool | Supported |
---|---|
redis- cli | Support |
Support | |
Not supported |
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 the instructions here very carefully:
- For Redis, the
substr
command has long been abandoned, so you should not use thesubstr
command in the Redis client (of course, you can do this Do, but youmustdo this) - If you are still thinking about Redis, then use the
getrange
command - Pay attention to the difference between the two Difference:
substr(start, size)
,getrange(start, end)
- When size is a negative number, if you are not familiar with the PHP language, then you will feel Somewhat strange
- The description of SSDB’s
substr
command is here
Key-Map(Hash)
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 the entire hash, then you must use the SSDB client to execute the hclear
command. The entire hash cannot be deleted using the Redis client.
Key-Zset
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 the entire zset, then you must use the SSDB client to execute the zclear
command. The entire zset cannot be deleted using the Redis client.
Key-List(Queue)
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 the entire list, then you must use the SSDB client to execute the qclear
command. The entire list cannot be deleted using the Redis client.