News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

ServerGrove.com:
MongoDB TTL collections
August 26, 2013 @ 09:30:47

On the ServerGrove blog today there's a new post talking about TTL collections in MongoDB - queries with a time-to-live set on the indexes - and includes how to use them in PHP.

MongoDB (v. 2.2+) provides a mechanism to expire data from collections by setting a TTL -time to live- on indexes. This is a great feature if you have data that needs to persist in the database for a specific period of time. The TTL feature allows you to expire data using the MongoDB daemon instead of having to create cron jobs to delete expired data. [...] The MongoDB daemon (mongod) checks regularly for documents in collections with a TTL and removes the expired documents.

Using it from PHP is relatively simple - all that's needed is a configuration parameter on the "ensureIndex" call setting an "expireAfterSeconds" value. There's also a bit included in the post for the Doctrine users out there, showing the docblock comment to use to set the value.

0 comments voice your opinion now!
mongodb ttl timetolive collections expire seconds tutorial

Link: http://blog.servergrove.com/2013/08/23/mongodb-ttl-collections/

blog comments powered by Disqus

Similar Posts

The Shadow Fox Network: Building a Better Blog - Part 1 & 2

DevShed: Using Timers to Benchmark PHP Applications

Stefan Mischook's Blog: Cannot load mysql extension error - Video Tutorial How To

Bnnx.com: Installing the Zend Optimizer

DevShed: Performing Basic Tasks with MySQL 4.1 and Above, using mysqli with PHP 5


Community Events





Don't see your event here?
Let us know!


community configure interview bugfix list introduction library laravel install release code application language wordpress unittest developer api framework podcast series

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework