0
Observations : 

1. SDIFF only works with Set. It doesn't support SortedSets.

Query :

  1. In absence of SDIFF, what can be used for Sorted set for similar use-case as SDIFF
martin
  • 49
  • 2
  • 10

1 Answers1

1
  1. Short answer is no. A Sorted Set has members and scores. Nothing more. However, you can easily store the metadata in another key in Redis using the entityId as part of the key. So, for example, if your entityId was foo you could store that metadata under a key name something like Entity:MetaData:foo. This key could be a simple String, or any data structure in Redis.

  2. Use ZDIFF. It's like SDIFF, but for Sorted Sets.

Guy Royse
  • 2,739
  • 12
  • 9
  • Do we need to make another call for getting top 10 entities? ZDIFF doesn't provide that functionality. Also i don't need sortedSet functionality for trackedEntities. Do i still need to make it a SortedSet for ZDIFF. – martin Mar 01 '22 at 10:21
  • Yes, you would need to make another call (or just do it in your code if you don't have too much data). ZDIFFSTORE works just like ZDIFF but stores the result in a new Sorted Set, which could be useful for this. And ZDIFF will allow you to pass in Sets or Sorted Sets. So trackedEntities can be a Set. – Guy Royse Mar 01 '22 at 13:50
  • Also, if you use ZDIFFSTORE, you'll probably want to delete the Sorted Set when you are done. Although you could leave it in memory for a bit to cache the results. Depends on the specifics of what you are trying to do. – Guy Royse Mar 01 '22 at 13:53
  • Unfortunately it is extremely costly operation for large input – martin Mar 03 '22 at 14:25