Giter VIP home page Giter VIP logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 20, 2024
Hello!

this is the right behavior. Write operations against volatile keys (keys with an
expire value associated) remove the key before to perform the operation. To 
check why
please read the manual for the EXPIRE command. It is explained in detail.

Original comment by [email protected] on 29 Apr 2009 at 3:35

  • Changed state: Invalid

from redis.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 20, 2024
Hi,

I have read the behaviour of EXPIRE before, but as I see it now, I didn't go 
into 
details enough. I just didn't expect that INCRBY would act the way it did...

I wonder if this is the right way to do it... Maybe it would be better to get 
an 
error response instead of setting completly wrong value to the key?

Original comment by [email protected] on 29 Apr 2009 at 4:44

from redis.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 20, 2024
Hello Davor, unfortunately to return an error does not work in order to have a 
time
independent data model: imagine the following:

{{{
PUSH foo 1
EXPIRE foo 1
... after some time ...
PUSH foo 2
}}}

The only way to ensure that the dataset will be the same both if the second 
push is
performed 1 millisecond after or five seconds after is to consider the key 
already
expired. This can appear an odd feature at first but I think in the long run it 
will
pay to have a very stable replication that is not related to the time factor.

Original comment by [email protected] on 29 Apr 2009 at 4:56

from redis.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 20, 2024
Hello Antirez, 

I've solved my problem with INCR & EXPIRE, by not using INCR at all:
{{{
SET a 5
EXPIRE a 60
... 
GET a
5
SET a 5+5
EXPIRE a 60
...
}}}
... it's not a very elegant solution, but it does the trick.

I've been thinking a bit more about this issue...  The INCR is an operation on 
existing key, but it also creates new key with default value 0 and then 
increments 
it in case it doesn't exists. The same thing goes for PUSH, it creates the list 
if 
there's no list... This is convenient, but it also produces unexpected 
behaviour in 
some cases.

The other thing is consistency around the nodes.. 
{{{
Master node:
12:00 PUSH foo 1 
12:01 EXPIRE foo 5
... after some time ...
12:05 PUSH foo 2

Node (~2 sec latency, master timestamp in [])
12:02 [12:00] PUSH foo 1
12:03 [12:01] EXPIRE foo 5 /* dies @ 12:06 */
... after some time ...
12:07 [12:05] PUSH foo 2 /* foo was still live @ 12:05 */
}}}
... in this case you know what to do with the second push - it could fail 
silently.

It's hard to imagine completely time independant model when EXPIRE is one of 
the 
available commands...

Original comment by [email protected] on 2 May 2009 at 8:32

from redis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.