Created
November 24, 2013 11:20
-
-
Save mklooss/7626105 to your computer and use it in GitHub Desktop.
Magento - MongoDB Cache cleaner for
https://github.com/colinmollenhour/Cm_Cache_Backend_Mongo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cfg = array( | |
'server' => 'mongodb://127.0.0.1:27017/?journal=false&w=1&wTimeoutMS=20000', | |
'db' => 'cm_cache', | |
'collection' => 'cm_cache' | |
); | |
// set to timezone to UTC, like magento do this | |
date_default_timezone_set('UTC'); | |
$conn = new MongoClient($cfg['server']); | |
$db = $conn->selectDB($cfg['db']); | |
$collection = $db->selectCollection($cfg['collection']); | |
// remove old cache | |
$collection->remove(array('e' => array('$lte' => new MongoDate()))); | |
// Delete data older than 1 month | |
$time = strtotime('-1 month'); | |
$collection->remove(array('m' => array('$lte' => new MongoDate($time)))); | |
echo "complete"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment