Get Current TTL / Age
I'm coming from Wincache, so forgive if I seem off-base. I'm using PHP, Windows, IIS.
Is there a way to determine current age or TTL left on a stored value?
Mainly to show last time since data has refrehed, so that a user can choose to manually refresh if they like.
Makes sense. I just want to point out that the data in the Couchbase bucket will always be the most recent and up to date. This is something that might be useful for a memcached bucket.
"I just want to point out that the data in the Couchbase bucket will always be the most recent and up to date."
I'm not sure what that means. How is that possible? If I set the data, it's stale until I set it again (or the TTL expires and I have to set it.) We use the caching to store data that changes, but is hard on the server to pull and changes are less frequent than user requests.
A Couchbase bucket provides persistence and will only keep the most recent value you put into the system because the cache and the persistence layer are linked together internally. The memcached bucket doesn't provide persistence and will have the problems you mentioned above. In other words I think your use case is valid for the memcached bucket, but not the Couchbase bucket since the problem you want to solve will not happen in the Couchbase bucket.
I think you are misunderstanding me. Let me try to explain it better:
* I put the data in a value, for my example, it's the records for a person's queue in our ticket system
* We don't refresh that data every single time the user loads the page, as it's a very slow query and changes are less frequent than page loads, so we cache for 60 seconds
* From the time that data is loaded until the 60 seconds is reached or the user clicks a link to manually refresh the page, or changes a ticket (which will initiate a refresh for that user only), that data is becoming stale
* With Wincache, I can show the user how old in seconds that data is, so they can choose to refresh early or now
I need this info to avoid dog-pile effect.
In pseudo-code:
x = get(key, ttl)
if (ttl < 5)
{
if (lock(key))
{
set(key, value)
unlock(key);
}
}
The standard memcached protocol doesn't provide a way to return this information. What your use case for needing this? I can add it as a feature request and in the future we could potentially provide a new command that retrieves this information.