Re: Expire for individual fields in a hash

2,433 views
Skip to first unread message

Salvatore Sanfilippo

unread,
Feb 21, 2011, 11:18:35 AM2/21/11
to redi...@googlegroups.com, Peter
Hi Peter,

sorry not possible and likely will never be implemented.
Sometimes you can roll your own expires using sorted sets. Depends on
the use case if it is appropriate or not to do this.

Cheers,
Salvatore

On Mon, Feb 21, 2011 at 5:15 PM, Peter <b8...@unb.ca> wrote:
> Hi everybody,
>
> The expire command is pretty good. However, it is only applicable to a
> key.
>
> Is it possible to set the expire for individual field in a hash?
>
> For example:
>
> HSET hash field1 "Hello"
>
> expire(hash, field1, 1000) ???
>
> Thank you.
> Peter
>
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
>
>

--
Salvatore 'antirez' Sanfilippo
open source developer - VMware

http://invece.org
"We are what we repeatedly do. Excellence, therefore, is not an act,
but a habit." -- Aristotele

Peter

unread,
Feb 21, 2011, 11:15:26 AM2/21/11
to Redis DB

Matt Palmer

unread,
May 6, 2013, 5:51:00 PM5/6/13
to redi...@googlegroups.com
On Sun, May 05, 2013 at 10:34:04PM -0700, 书记的马甲 wrote:
> Recently I came accross the same ocurence. When I use session, I want to
> save sessino-ids of users, so my code same as:
>
> key = 'myapp:session:' + session_id
> set key session_value
> expire key 3600 * 24 * 7
>
> But I have many many users, that's to say it will save a lot of
> 'myapp:session:' in the memeroy.So I want to use the hash type in redis:
>
> key = 'myapp:session'
> hset key session_id session_value
> here, I can't expire the session_id.

I'd suggest just living with the fact that you'll have 14 bytes repeated
many times, and using regular keys. Adding expiry logic (and the associated
commands, etc) to hashes would be a fair amount of effort for very little
gain, given that we already have a hash type with expirations (regular
keys). You'd probably find (and provide) more benefit by working out some
way to compress keys in memory.

- Matt

--
"I have a cat, so I know that when she digs her very sharp claws into my
chest or stomach it's really a sign of affection, but I don't see any reason
for programming languages to show affection with pain."
-- Erik Naggum, comp.lang.lisp

Bate David

unread,
Jul 21, 2015, 9:53:56 AM7/21/15
to redi...@googlegroups.com, b8...@unb.ca
hi Salvatore
Is it possible to set the expire for individual field in a hash now?

Salvatore Sanfilippo

unread,
Jul 21, 2015, 9:55:03 AM7/21/15
to Redis DB, Peter
No... sorry this feature is not planned.

Cheers,
Salvatore

On Tue, Jul 21, 2015 at 3:24 PM, Bate David <yuhuic...@gmail.com> wrote:
> hi Salvatore
> Is it possible to set the expire for individual field in a hash now?
>
> --
> 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 http://groups.google.com/group/redis-db.
> For more options, visit https://groups.google.com/d/optout.



--
Salvatore 'antirez' Sanfilippo
open source developer - Pivotal http://pivotal.io

"If a system is to have conceptual integrity, someone must control the
concepts."
— Fred Brooks, "The Mythical Man-Month", 1975.
Reply all
Reply to author
Forward
0 new messages