As was answered, there's no built-in way to determine when a key was set. Furthermore, memcached itself doesn't track when the oldest key changes. The only way to approximate the behavior you want is to store the set times in each value, get all possible keys, and then do the comparison yourself. This will not be fast or efficient.
I suggest taking a step back k and talking about the higher-level gioal you're trying to accomplish that makes you think you need the time the oldest key was set. There may be a good way to accomplish your actual goal without this information. ~Ryan On Jan 16, 2015 2:24 AM, "Gurdipe Dosanjh" <[email protected]> wrote: > Hi All, > > Thank you for the updates. > > I have been doing a lot of reading on memcached and I am trying to find a > way I can find out what is the oldest key. > > Is there a way I can do this? > > Kind Regards > > Gurdipe > > Kind Regards > > Gurdipe > > Email: [email protected] > Mobile: 07879682511 > Home: 01656749236 > Skype: gurdipe_veeqo > Linkedin: gurdipe > Dropbox: [email protected] > > > On 12 January 2015 at 20:49, 'Jay Grizzard' via memcached < > [email protected]> wrote: > >> Ack! You are, of course, right. I looked at the protocol documentation >> and completely failed to engage my brain enough to realize that the >> protocol documentation is… imprecise. Or at least unclear. Or at least >> lacks an appropriate definition of ‘age’. >> >> My bad! >> >> -j >> >> On Mon, Jan 12, 2015 at 12:14 PM, dormando <[email protected]> wrote: >> >>> The only data stored are when the item expires, and when the last time it >>> was accessed. >>> >>> The "age" field (and evicted_time) is how long ago the oldest item in the >>> LRU was accessed. You can roughly tell how wide your LRU is with that. >>> >>> On Mon, 12 Jan 2015, 'Jay Grizzard' via memcached wrote: >>> >>> > I don’t think there’s a way to figure out when a given key was >>> written. If you really needed that, you could write it as part of the data >>> you >>> > stored, or use the ‘flags’ field to store a unixtime timestamp. >>> > You can get the age of the oldest key, on a per-slab basis, with >>> ‘stats items’ and looking at the ‘age’ field. If you want the overall >>> oldest age, >>> > you’ll have to find the oldest age value amongst all the slabs. >>> > >>> > Do note, though, that if you have evictions going on, ‘oldest’ is kind >>> of dubious, if you’re trying to use it as a “anything newer than this >>> > exists”, since evictions happen in lru order and per-slab, so younger >>> items can disappear before older ones, if they’re in a different slab or >>> have >>> > been accessed more recently. (Don’t know if that’s what you’re doing, >>> but just in case you are…) >>> > >>> > -j >>> > >>> > >>> > On Mon, Jan 12, 2015 at 9:34 AM, Gurdipe Dosanjh <[email protected]> >>> wrote: >>> > Hi All, >>> > >>> > I am new to memcache and need to know is there a where to work out >>> when the key was written to memcache and calculate the age of the oldest >>> > key on our memcache? >>> > >>> > Kind Regards >>> > >>> > Gurdipe >>> > >>> > -- >>> > >>> > --- >>> > You received this message because you are subscribed to the Google >>> Groups "memcached" group. >>> > To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> > For more options, visit https://groups.google.com/d/optout. >>> > >>> > >>> > -- >>> > >>> > --- >>> > You received this message because you are subscribed to the Google >>> Groups "memcached" group. >>> > To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> > For more options, visit https://groups.google.com/d/optout. >>> > >>> > >>> >> >> -- >> >> --- >> You received this message because you are subscribed to a topic in the >> Google Groups "memcached" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/memcached/D4Szg9tsaS0/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- > > --- > You received this message because you are subscribed to the Google Groups > "memcached" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- --- You received this message because you are subscribed to the Google Groups "memcached" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
