13

When you put a value in memcached, you can set an expiration time.

However, when you increment a value you can not (at least not from PHP) set a new expiration time.

My question: Is the expiration time reset on increment to it's initial value? Or it it unchanged? Or is there another way to regenerate the expiration time?

Both the memcache documentation is vague about this, as well as the PHP documentation

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
Toad
  • 15,593
  • 16
  • 82
  • 128

1 Answers1

19

I just needed know this as well. A little experiment can tell us: expiration time is NOT updated after an increment. That's it.

KailZhang
  • 238
  • 3
  • 6
  • i've actually moved to redis for things like counters. It's as fast, persistent and optimized for things like counters, set manipulation and queues/lists/stacks – Toad Nov 03 '10 at 06:43
  • Both for the binary and ascii protocols? The ascii protocol doesn't allow specifying an expiration when incrementing, but the binary protocol has a field for expiration which is used when initially creating the counter (possible with binary protocol, but not ascii). The memcached binary protocol docs doesn't explicitly say if the expiration given is ignored when incrementing an existing counter, or if the expiry-timer is reset. – Stefan L Aug 08 '13 at 08:39