Today we found that a value in the Redis database is always 1, but it does incr n many times for this value in the program
After each incr, set a expire time, try to expire this sentence after the note, this value has been growing
Isn't it expire wrong. Looked up the official document of Redis, yes, so I tested it myself.
debian:~$ redis-cli
redis> incr dd
(integer) 1
redis> incr dd
(integer) 2
redis> incr dd< c5/> (integer) 3
redis> incrby dd
(integer)
redis> expire dd
(integer) 1
redis> Get DD
redis> incr dd
(integer) 1
Originally in expire, then INCR will start again from 1, no wonder I that value is always, this is obviously a bug.
First look at the Redis version with dpkg.
debian:~$ dpkg-l redis-server
desired=unknown/install/remove/purge/hold
| Status=not/inst/conf-files/unpacked/half-conf/half-inst/trig-await/trig-pend
|/Err?= (none)/Reinst-required (Status,err:uppercase=bad)
| | /Name Version Description
+++-============================-============================-========== ==============================================================
II redis-server 2:1.2.6-1 Persistent Key-value database with network interface
The original is 1.2.6, now the latest Redis are 2.4.4 AH. The software version on Debian is old enough. My Debian is the newest Debian 6.
So I downloaded the Redis code, after compiling, with a new version of the test
1. Download decompression
wget http://redis.googlecode.com/files/redis-2.4.4.tar.gz
tar-zxf redis-2.4.4.tar.gz
2. Compile
CD redis-2.4.4 make
3. Run
Change the redis.conf first, change the daemonize to Yes, change the port to 6378, and start the Redis
./src/redis-server redis.conf
4. Test,
It's the same as in the old version, but the results are correct. Expire after incr, not starting from 1.
debian:~/software/redis-2.4.4$ redis-cli-p 6378
redis> incr dd
(integer) 1
redis> incr DD
( Integer) 2
redis> incr dd
(integer) 3
redis> incrby dd
(integer)
redis> expire DD 600< c10/> (integer) 1
redis> get dd
redis> incr dd
(integer) 54