Migrate from Redis to SSDB


Tools

The redis-import.php PHP script in the tools directory can be used to put the Redis server on the The data is copied to the SSDB server.

Usage:

php redis-import.php redis_host redis_port redis_db ssdb_host ssdb_port

Parameters:

  • redis_host: Redis The IP or host name where the SSDB is running
  • redis_port: The port that Redis listens on
  • redis_db: The DB number of Redis
  • ssdb_host: The IP or host name where the SSDB is running
  • ssdb_port: SSDB listening port

Please make sure your PHP Redis module https://github.com/nicolasff/phpredis has been installed.

Redis Tool Support

##TwemproxySentinel

SSDB and Redis command comparison table

SSDB supports the Redis protocol and client, so you can use the Redis client to connect to SSDB for operations.

However, if you want to use SSDB client, you may need the following command comparison table.

Key-Value

ToolSupported
redis- cliSupport
Support
Not supported
RedisSSDB
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 the instructions here very carefully:

  • For Redis, the substr command has long been abandoned, so you should not use the substr 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)

RedisSSDB
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 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

RedisSSDB
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 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)

RedisSSDB
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 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.