Last active
January 1, 2016 18:19
-
-
Save ericsk/8183103 to your computer and use it in GitHub Desktop.
WindowsAzureSessionHandler 的 gc 方法
This file contains hidden or 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
/** | |
* Callback function for session handler. It's invoked while the session garbage collection starts. | |
* | |
* @param $lifeTime Specify the expiry time for cleaning outdated sessions. | |
* | |
* @return boolean If the gc operation success. | |
*/ | |
public function gc($lifeTime) { | |
// search the entities that need to be deleted. | |
$filter = 'PartitionKey eq\'' . $this->_sessionContainerPartition . '\' and expires lt ' . (time() - $lifeTime); | |
try { | |
$result = $this->_tableRestProxy->queryEntities($this->_sessionContainer, $filter); | |
$entities = $result->getEntities(); | |
foreach ($entities as $entitiy) { | |
$this->_tableRestProxy->deleteEntity($this->_sessionContainer, $this->_sessionContainerParition, $entity->getRowKey()); | |
} | |
return TRUE; | |
} catch (ServiceException $e) { | |
return FALSE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment