Documents never expire?

So I’ve been using Couchbase for a few months, and I’m having an issue with document expiry.

I’m calling the following code:

$connection = new \CouchbaseCluster(SYS_COUCHBASE_HOSTS);
$bucket = $connection->openBucket(‘cache’, SYS_COUCHBASE_PASSWORD);
$bucket->insert(‘abc123’, [‘value’ => 123456], [‘expires’ => 3]);
sleep(10);
print_r($bucket->get(‘abc123’));

And I get the value I put in back - this seems completely wrong to me!

This happens for both couchbase AND memcache buckets; and if I specific expiry as 3 or time()+3 (should be the same, according to docs) - it just never expires. Even 24 hours later the same value is in the database.

However…

In the same Couchbase instance, I have a default bucket using the memcached PHP extensions, and the serialized sessions are correctly expired here - so this point to being a PHP Extension issue to me…

PHP version: 5.6.9, 5.6.11, 5.6.12 (tried on multiple machines)
Couchbase PHP Extension version: 2.0.7
Libcouchbase version: 2.4.1 or 2.4.9

Server version: 3.0.1 Community Edition (build-1444).

Any ideas?

Thanks,

Joe

Hey @brett19 can you provide any php solution here please

Hey joe_bowman,

Please use expiry rather than expires.

Cheers, Brett

Sorry for the slow reply.

I had a situation where it appeared that documents weren’t expiring in a production environment. My reduced case for testing used expires instead of expiry - the original code was correct.

It turns out the documents are expiring, just at a far far slower rate than they are being created. This should flatten out over time (I hope!).

Thanks again for your clarification @brett19, and thanks for your excellent work on the extension. It is much appreciated.

1 Like