Could I change redis data structure list to set -


i used redis list structure store data, want change list type set. command this?

no built-in way that. need manually items list , insert set. if list small, can use following lua script:

repeat     local item = redis.call('lpop', keys[1])     if (item) redis.call('sadd', keys[2], item) end until not item 

however, if list large, script block redis long time. have incrementally move items list set:

  1. call lrange items (small batch) list
  2. call sadd insert these items set
  3. call ltrim remove these items list
  4. go step 1 until items have been moved.

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -