thepirat000 / CachingFramework.Redis

Distributed caching based on StackExchange.Redis and Redis. Includes support for tagging and is cluster-compatible.
Other
287 stars 52 forks source link

Work with data value in Redis key #49

Closed minhncud closed 6 years ago

minhncud commented 6 years ago

I stored a list object (contains ID and values) to a key on Redis and i want to update it without remove that key and insert again. I need get a smaller list object, insert new object, remove last object or edit an object.

  1. If i store list object by Json string, maybe i need use EVAL with Lua script but i don't know about Lua
  2. If i store list object by Hash, i don't know how to get range in the Hash key.
    • Example of Hash: Store list<string,string> Object : { (id1, value1), (id2, value2), (id3, value3), (id4, value4), (id5, value5), (id6, value6) } Need get { (id3, value3), (id4, value4) } for object1
  3. If i store list object by Sortset, how can i update value with a score (if i use score instead of field in Hash)?

Can you help me that? Thanks. _ Edit: I think Hash is the best choice, so can i get smaller list object instead of getting all and filter in server? Because i use GetHashedAll to get 60 fields in a key, it run in ~2s. Thank you.

thepirat000 commented 6 years ago

I think this is a general redis data design question. And it really depends on how are you going to access data. i.e. if you always retrieve a small set of the hash keys, you probably don't need range queries, and can do it with multiple HGET or HMGET

thepirat000 commented 6 years ago

Didn't wanted to close this yet, sorry.

You should be able to get multiple hash fields with RedisDictionary collection GetRange method, which uses Redis HMGET.

Also, if your field keys are strings, you can use ScanHashed method on RedisCacheProvider. It internally uses the Redis HSCAN command.

minhncud commented 6 years ago

Yeah, you've just inserted GetRange, right? Yesterday i don't see it in RedisDictionary.cs. And is your new master project does not automatically get Nuget's packages? I can not build it to test :(

thepirat000 commented 6 years ago

yes, I've added some missing methods.

Will check the build error

thepirat000 commented 6 years ago

I can't reproduce the build problem.

Just did the following and it compiles with no errors:

git clone https://github.com/thepirat000/CachingFramework.Redis.git
dotnet build CachingFramework.Redis
minhncud commented 6 years ago

Although i can not debug by add a new project which has dependencies base on your master projects. Errors about version of Newsonsoft.Json, StackExchange.Redis. If i get them manually, new error Could not load file or assembly "CachingFramework.Redis, Version=10.0.1.0, Culture=neutral, PublicKeyToken=3982df00cecbd320" happened. But using the newest version of CachingFramework.Redis in a single project solution, it works well, thank you very much :D

Not this problem but the Configuration.md link to StackExchange.Redis of your home page is typed wrong "Docs" vs "docs": "The constructor parameter must be a valid StackExchange.Redis connection string. Check this for more information about StackExchange.Redis configuration options." you set this to link "https://github.com/StackExchange/StackExchange.Redis/blob/master/Docs/Configuration.md" -> 404 not found because the real link is "https://github.com/StackExchange/StackExchange.Redis/blob/master/docs/Configuration.md"