I used HashSet to add a List

How can i handle values of those rows to get with sorting, paging, update....:
For Sorting, I tried using SortSet but 2 rows can have the same score so i change to hash.
Can i use list (string json) instead of hash? Because if i can handle values, hashkey is not important.
Normally, redis values are opaque blobs/clobs to redis. It doesn't
usually have much interest in what the insides are, so if you're trying to
do this server side, then there isn't a simple answer with the data
shown, because that isn't something that redis supports. It looks like
you're using JSON, in which case you might be interested in the "cjson"
support that Redis adds into Lua. A discussion of that is here:
https://www.redisgreen.net/blog/intro-to-lua-for-redis-programmers/
To use Lua from SE.Redis, see the ScriptEvaluate method.
Another option for single keys would be the ReJSON module for Redis 4.* (
http://rejson.io/). This adds entire new redis commands, which you can
invoke via Execute on SE.Redis.
Alternatively, you could store the data in native redis structures, but
that would involve a redesign. For example, a sorted-set for sorting the
data by date.
Marc
On 1 March 2018 at 10:34, minhncud notifications@github.com wrote:
I used HashSet to add a List with Json values to redis server. (example: a
key has 4 rows)[image: redis-ask]
https://user-images.githubusercontent.com/36953180/36839640-2c649652-1d75-11e8-8a49-b84a893f242a.pngHow can i handle values of those rows to get with sorting, paging,
update....:
- Get 2 rows order by date ('born' in value) desc / get rows by name
- Update: Delete oldest row and insert new row.
(Please answer with c# command (for example), I read code better than
read and translate English, thank you)For Sorting, I tried using SortSet but 2 rows can have the same score so i
change to hash.
Can i use list (string json) instead of hash? Because if i can handle
values, hashkey is not important.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/StackExchange/StackExchange.Redis/issues/790, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AABDsIAwiX3ItAVqGEgx6Dz4QVOXNFZQks5tZ86bgaJpZM4SYFmP
.
--
Regards,
Marc
Thank you mgravell,
In file rejson-master, i see C library and Python test. My bad, i begin with VS and use single language C# so i don't know how to use this.
I'm happy when read your plan at "http://blog.marcgravell.com/2017/04/stackexchangeredis-and-redis-40-modules.html". As i understand, that plan became 'ScriptEvaluate' in SE.Redis, right?
Do i have to install lua cjson?
Another, if i don't use Json, can i compare 2 values of 2 row in the same key using ScriptEvaluate?
Thanks.
As i understand, that plan became 'ScriptEvaluate' in SE.Redis, right?
Are you interested in the Lua JSON option? or the ReJSON (module) option? They are very different.
ScriptEvaluate is used for Lua. As I understand it, cjson is automatically available inside Lua inside Redis. You wouldn't need to install anything.
ReJSON is a module. To work with modules, the Execute method is the way to go. You need to install modules on the server, and this works with Redis 4.* and above only.
Another, if i don't use Json, can i compare 2 values of 2 row in the same key using ScriptEvaluate?
Define "compare". Compare what 2 values of what 2 rows? Sorry, but the details really matter. If you mean "the two values are strings that contain json, and in the json there is a field called 'foo'; can I compare the value of 'foo' between two rows?" - they yes you can do that on the server via Lua and cjson. The first link provided previously should show you how to do this.
Thanks mgravell, I'm interested in Lua JSON option. Do you have any sample or demo-project using ScriptEvaluate? (Did your first link about Lua show console or C language? Can you wrote a simple command by C#?)
About "compare", i mean if values don't contains json.
Example I add a list string to redis:

Then i want to check rows with the same value to get no duplicate values or get last updated values...
If it's not more simple, i will save like a json string.
You seem to have switched to a list now. A list does not have an "is member" test. You might be better off using a set or sorted set. For set, there is SISMEBER, but a set is unordered. A sorted set can use ZSCORE to test for inclusion, and can be ordered like a list by using the index as the score.
Useful reference: https://redis.io/commands - note the "group" filter at the top that allows you to filter to lists/sets/etc
yes, commands of redis.io are useful, but i don't know how to connect it with SE.Redis. Example HSET in command is SE.Redis.HashSet, right? I can't find a document which shows switching command between Redis and SE.Redis.
Can i ask you about a personal problem not about this issue?
My situation is using Redis to reduce requests from web to database.
So i choose using Redis like a temporary database instead of Sql Server. It means i have to rewrite sql table by json string, add to a key in redis and work with it. I use HashSet for this (it's the reason i create this issue)
Second, i use Redis Cache to save a partial view (MVC) like html string which rarely updates. So i think i can use list to save them but your idea about SortedSet is helpful. Thanks.
Am i right when i choose this way to resolve my problem?
Am i right when i choose this way to resolve my problem?
It really comes down to: does it work for you?
Can SE.Redis execute those commands directly without lua?
It cannot access cjson, if that is what you mean. SE.Redis works at the
redis command level; cjson is not part of that.
On 2 March 2018 at 11:57, minhncud notifications@github.com wrote:
yes, commands of redis.io are very useful, but i don't know how to
connect it with SE.Redis. Can SE.Redis execute those commands directly
without lua?Can i ask you about a personal problem not about this issue?
My situation is using Redis to reduce requests from web to database.
So i choose using Redis like a temporary database instead of Sql Server.
It means i have to rewrite sql table by json string, add to a key in redis
and work with it. I use HashSet for this (it's the reason i create this
issue)
Second, i use Redis Cache to save a partial view (MVC) like html string
which rarely updates. So i think i can use list to save them but your idea
about SortedSet is helpful. Thanks.
Am i right when i choose this way to resolve my problem?—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/StackExchange/StackExchange.Redis/issues/790#issuecomment-369902520,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABDsAEpeDibySxEf_SblduckATMBXkBks5taTOWgaJpZM4SYFmP
.
--
Regards,
Marc
I'm sorry about slow reply. Yes, it's my work. I read careful and I understood. Thank you very much, i'll close this issue :)