添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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:

  • redis_host: The IP address or hostname of Redis instance
  • redis_port: The port number of Redis instance
  • redis_db: Which Redis database(a number) you want to copy from
  • ssdb_host: The IP address or hostname of SSDB instance
  • ssdb_port: The port number of SSDB instance
  • Make sure you have the PHP Redis module https://github.com/nicolasff/phpredis installed.

    Supported Redis Tools

    Supported

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

  • 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)
  • use getrange instead if you are sticking your mind with Redis
  • notice the difference between substr(start, size) and getrange(start, end)
  • when size is negative, the behavior may be strange for those who are not familiar with PHP language
  • substr in SSDB works as described here
  • Key-Map(Hash)

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