Created
March 22, 2013 20:22
-
-
Save jonathandavis/5224447 to your computer and use it in GitHub Desktop.
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
/** | |
* Garbage collection routine for cleaning up old and expired | |
* sessions. | |
* | |
* 1.3 Added support for shopping session cold storage | |
* | |
* @author Jonathan Davis | |
* @since 1.1 | |
* @version 1.3 | |
* | |
* @return boolean | |
**/ | |
function purge () { | |
if (empty($this->session)) return false; | |
$timeout = SHOPP_SESSION_TIMEOUT; | |
$now = current_time('mysql'); | |
$meta_table = DatabaseObject::tablename('meta'); | |
DB::query("INSERT INTO $meta_table (parent,context,type,name,value,created,modified) | |
SELECT session,'shopping','session','coldstorage',data,created,modified FROM $this->_table WHERE $timeout < UNIX_TIMESTAMP('$now') - UNIX_TIMESTAMP(modified) AND shopping=1"); | |
if (!DB::query("DELETE LOW_PRIORITY FROM $this->_table WHERE $timeout < UNIX_TIMESTAMP('$now') - UNIX_TIMESTAMP(modified)")) | |
trigger_error("Could not delete cached session data."); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment