Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 1.8.x

Get Current TTL / Age

7 replies [Last post]
  • Login or register to post comments
Thu, 05/17/2012 - 13:41
laurin1
laurin1's picture
Offline
Joined: 05/17/2012
Groups: None

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?

Top
  • Login or register to post comments
Wed, 05/23/2012 - 10:47
mikew
Offline
Joined: 03/14/2011
Groups:

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.

Top
  • Login or register to post comments
Wed, 05/23/2012 - 11:46
laurin1
laurin1's picture
Offline
Joined: 05/17/2012
Groups: None

Mainly to show last time since data has refrehed, so that a user can choose to manually refresh if they like.

Top
  • Login or register to post comments
Wed, 05/23/2012 - 13:17
mikew
Offline
Joined: 03/14/2011
Groups:

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.

Top
  • Login or register to post comments
Wed, 05/23/2012 - 13:20
laurin1
laurin1's picture
Offline
Joined: 05/17/2012
Groups: None

"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.

Top
  • Login or register to post comments
Wed, 05/23/2012 - 15:12
mikew
Offline
Joined: 03/14/2011
Groups:

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.

Top
  • Login or register to post comments
Wed, 05/23/2012 - 15:16
laurin1
laurin1's picture
Offline
Joined: 05/17/2012
Groups: None

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

Top
  • Login or register to post comments
Sat, 01/19/2013 - 07:42
OZ
Offline
Joined: 01/18/2013
Groups: None

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);
}
}

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker