Redis Hash fields expiry time

2,913 views
Skip to first unread message

Shushant Arora

unread,
Dec 8, 2017, 6:30:00 AM12/8/17
to Redis DB
Hi

I have a hashfield in redis .

 hmset 'U1' 'f1' 'v1'

 hmset 'U1' 'f2' 'v2'


Is it possible to set eviction time of f1 to 15 minute and eviction of f2 to 30 minutes ?

Also what's recomendation for max keys in hash field.
Say My hash Field U1 can it have 1000 hash keys ? Will it impact performance ?

Itamar Haber

unread,
Dec 8, 2017, 9:46:47 AM12/8/17
to Redis DB
Hello Shshant,

> Is it possible to set eviction time of f1 to 15 minute and eviction of f2 to 30 minutes ?

Redis provide key-level expiration only, and nested element expiration (i.e. fields in Hashes, members in Sets, etc...) is not supported. Put differently, you can't expire individual fields in a Hash.

Also what's recomendation for max keys in hash field.

That depends on your data and the operations you perform on it. Hashes demonstrate constant access time regardless their size, so for single field access size is irrelevant. However, fetching an entire Hash's fields is an operation of complexity depending on the number of fields, so the more fields there are the less "performant" it will be.

Cheers,

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+unsubscribe@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.



--

Itamar Haber | Chief OSS Education Officer
Redis Labs ~/redis

Mobile: +972 (54) 567 9692
Twitter: @itamarhaber
Skype: itamar.haber

Shushant Arora

unread,
Dec 8, 2017, 12:40:59 PM12/8/17
to redi...@googlegroups.com
Ok..

say I need to fetch only 3 or 4 fields at a time from hash Key, but My hash key contains ~10k of fields will it be efficient and O(1)

--
You received this message because you are subscribed to a topic in the Google Groups "Redis DB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/redis-db/jbr7sXToIFg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to redis-db+unsubscribe@googlegroups.com.

hva...@gmail.com

unread,
Dec 8, 2017, 1:39:13 PM12/8/17
to Redis DB
Sounds like you're asking about HMGET.  The time complexity is given at the top of the documentation page:  https://redis.io/commands/hmget

("O(N) where N is the number of fields being requested.")



On Friday, December 8, 2017 at 9:40:59 AM UTC-8, Shushant Arora wrote:
Ok..

say I need to fetch only 3 or 4 fields at a time from hash Key, but My hash key contains ~10k of fields will it be efficient and O(1)
On Fri, Dec 8, 2017 at 8:16 PM, Itamar Haber <ita...@redislabs.com> wrote:
Hello Shshant,

> Is it possible to set eviction time of f1 to 15 minute and eviction of f2 to 30 minutes ?

Redis provide key-level expiration only, and nested element expiration (i.e. fields in Hashes, members in Sets, etc...) is not supported. Put differently, you can't expire individual fields in a Hash.

Also what's recomendation for max keys in hash field.

That depends on your data and the operations you perform on it. Hashes demonstrate constant access time regardless their size, so for single field access size is irrelevant. However, fetching an entire Hash's fields is an operation of complexity depending on the number of fields, so the more fields there are the less "performant" it will be.

Cheers,
On Fri, Dec 8, 2017 at 1:30 PM, Shushant Arora <shushan...@gmail.com> wrote:
Hi

I have a hashfield in redis .

 hmset 'U1' 'f1' 'v1'

 hmset 'U1' 'f2' 'v2'


Is it possible to set eviction time of f1 to 15 minute and eviction of f2 to 30 minutes ?

Also what's recomendation for max keys in hash field.
Say My hash Field U1 can it have 1000 hash keys ? Will it impact performance ?

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.

To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.



--

Itamar Haber | Chief OSS Education Officer
Redis Labs ~/redis

Mobile: +972 (54) 567 9692
Twitter: @itamarhaber
Skype: itamar.haber

--
You received this message because you are subscribed to a topic in the Google Groups "Redis DB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/redis-db/jbr7sXToIFg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to redis-db+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages