Migrate from Redis to SSDB

Tools

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.

Supported Redis Tools

Tool Supported
redis-cli Yes
Twemproxy Yes
Sentinel No

SSDB vs Redis Commands

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.

Key-Value

Redis SSDB
getget
setset
setexsetx(for kv type only)
deldel
incr/incrByincr
decr/decrBydecr
mget/getMultiplemulti_get
setMultiplemulti_set
del(multiple)multi_del
keyskeys(for kv type only)
getsetgetset
setnxsetnx
existsexists
ttlttl
expireexpire
getbitgetbit
setbitsetbit
bitcountredis_bitcount, countbit
strlenstrlen
getrangegetrange

Please read these notes very carefully:

Key-Map(Hash)

Redis SSDB
del(not supported)hclear
hgethget
hsethset
hdel, hmdelhdel, multi_hdel
hIncrByhincr
hDecrByhdecr
hKeyshkeys
hValshscan
hMGetmulti_hget
hMSetmulti_hset
hLenhsize
hExistshexists
keyshlist(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.

Key-Zset

Redis SSDB
del(not supported)zclear
zScorezget
zAddzset
zRemzdel
zRangezrange
zRevRangezrrange
zRangeByScorezscan
zRevRangeByScorezrscan
zIncrByzincr
zDecrByzdecr
zCountzcount
zSumzsum
zAvgzavg
zCardzsize
zRankzrank
zRemRangeByRankzremrangebyrank
zRemRangeByScorezremrangebyscore
keyszlist(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.

Key-List/Queue

Redis SSDB
del(not supported)qclear
llen/lsizeqsize
lpushqpush_front
rpushqpush_back
lpopqpop_front
rpopqpop_back
lrangeqslice
lindex, lgetqget
lsetqset
keysqlist(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.