> I thought this was a FAQ -- or at least I have memory of this being discussed 
> here before.
>
> I have one process that uses memcached for throttling by setting a key with a 
> timeout.  If the set fails (NOT_STORED, as the FAQ describes)
> then the process waits.
>
> The question came up yesterday at work if a process can query the time 
> remaining for a given key.  I thought I remembered that there was no
> way to read the timeout value on an existing key, but I'm not having any luck 
> this morning finding discussion of this.  Can someone confirm
> this -- or point me to documentation/discussion about this?

No way to fetch this in the protocol... You can embed it in your object if
you want.

> Also, Is there a way to test that a key exists other than a get()?  I know 
> with the throttling example an add() is used, but I don't want
> to add a new value if it doesn't exist.  Perhaps premature optimization, but 
> can a process check that a key exists and not transfer the
> value when the data is not needed?

No dice there either. You can do an 'add' of a zero byte object with an
expiration of 1 second. Or uh... if you set the expiration to be > 30 days
it's accepted as a date, so I think you can backdate it and have it expire
immediately? Can't remember offhand if that actually works.

Usually it's a premature optimization or a flow problem if you need to do
that though. Real cases have been rare.

-- 
To unsubscribe, reply using "remove me" as the subject.

Reply via email to