Skip to content

Instantly share code, notes, and snippets.

@ericsk
Last active January 1, 2016 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericsk/8183103 to your computer and use it in GitHub Desktop.
Save ericsk/8183103 to your computer and use it in GitHub Desktop.
WindowsAzureSessionHandler 的 gc 方法
/**
* 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