memcached (spymemcached) counters and expiry time
NickName:PapaFreud Ask DateTime:2012-08-21T15:49:22

memcached (spymemcached) counters and expiry time

can anybody tell me (or point to some documentation that documents) how memcached counters work? Specifically: how do they expire? I'm using the java spymemcached client.

The method

net.spy.memcached.MemcachedClient.incr(String key, int by, long def, int exp) 

takes a parameter "exp" described as "the expiration of this object"

Does that mean each individual call to the counter has its own expiry time? Or does calling incr bump the expiry time for the key?

Also, shouldn't there be a method to get a counter value? Or should I call incr with an increment of 0?

Copyright Notice:Content Author:「PapaFreud」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/12050407/memcached-spymemcached-counters-and-expiry-time

Answers
emcconville 2012-08-21T14:16:25

The int exp will overwrite the existing expiration time, and \"bump\" the key your incrementing. Check out the protocol docs for additional info.\n\n\n Also, shouldn't there be a method to get a counter value? Or should I\n call incr with an increment of 0?\n\n\nYou can get the value of the counter cell by using MemcachedClient.get method. The counter cell will need to be set from MemcachedClient.set before you are able to increment it. I'm not 100% sure about spymemcached, but some memcached libraries will auto set the counter cell to 0 -- before incrementation. \n\nA note on expiration time. If the int expr is -1 memcached will use the previous expiration time. If int expr is greater than 2592000 (30 days), it will be treated as an UNIX timestamp.",


More about “memcached (spymemcached) counters and expiry time” related questions

memcached (spymemcached) counters and expiry time

can anybody tell me (or point to some documentation that documents) how memcached counters work? Specifically: how do they expire? I'm using the java spymemcached client. The method net.spy.mem...

Show Detail

SpyMemcached and Memcached: SpyMemcached.getInstance(memcache.job) is invalid! check memcached.property

[2011-08-29 10:05:09.132]ALERT: SpyMemcached.getInstance(memcache.job) is invalid! check memcached.property . [2011-08-29 10:05:54.590]ALERT: SpyMemcached.getInstance(memcache.job) is invalid! check

Show Detail

Spymemcached issue with 2 nodes configured

I am using Ketama algorithm's spymemcached for my project. I do have two memcached servers running as part of HA (high availability) and my configurations are hibernate.cache.use_second_level_cach...

Show Detail

memcached entry expiration set to 0

Does memcached entries with expiry time set to 0 not expire - as mentioned in the PHP Memcached docs, but not mentioned in the memcached protocol spec? I am using spymemcached client and the docs ...

Show Detail

Items set with spymemcached cannot be fetched with php memcached

I am using spymemcached. I set a couple of items. Then I run a php script, however then I cannot get all those items using php memcached. PHP-Memcached can only partially retrieve those items. I c...

Show Detail

How to cache a Memcached connection using the java spymemcached client

I am learning how to cache objects using memcached with the spymemcached client from spymemcached examples MemcachedClient c=new MemcachedClient(new InetSocketAddress("hostname", portNum)); //...

Show Detail

spymemcached (Java Memcached Client)

Is there a way to collect the memcached stats using this API (spymemcached)? I know there are tools like cacti to collect information on Memcached Server. But I would like to collect, say, memory ...

Show Detail

Memcached consistent hashing - spymemcached

I want to have memcached consistant hashing enabled. I've looked at phpinfo(); and I can see the following - last line "memcached.sess_consistent_hash": memcached memcached support enabled Vers...

Show Detail

Java (spymemcached) and PHP (memcached)

I'm trying to build a Java app that will set data in Memcached and have a PHP script to get the same data later in the process. So far, I haven't been able to find a way to get a 100% hit rate. To ...

Show Detail

how to swap between two cache keys with CAS with memcached / spymemcached

I have a cache object (large json object) associated with a key. I would like to switch between this cache object / key instance and another without any down time in availability in one of the two...

Show Detail