Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
532 views
in Technique[技术] by (71.8m points)

java - Efficient way redis set member update

I have a redis set. This set can store 20 members maximum(added withSADD command). My problem is ; I need to update that members when needed. Members need that modification maximum 10 times for every member. Set members are json as a string. There is only solutoin on my mind nor, get all members update and recreate that set again. But it seems iditoic.

I know there is ZADD sorted set with its score support it seems suitable also I need to update score like data in json , but i just wonder Is there any method updating members in efficient way, or is updating member not acceptable on redis way ?

Note: Redis datastore is using by both node.js and java clients.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Set members themselves are immutable - you can add new members or remove existing ones. That's it.

Given that a set is an unordered collection of unique members, consider the possible outcomes were set members theoretically modifiable when the new value for a member:

  1. is identical to the old value - no change to the set
  2. already exists in the set - equivalent to deleting that member
  3. isn't 1 or 2 - equivalent to deleting the member and adding a new one

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...