Skip to content
Snippets Groups Projects
Commit c0801679 authored by Olav Morken's avatar Olav Morken
Browse files

Memcache: Add $expire parameter to set().

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2488 44740490-163a-0410-bde0-09ae8108e29a
parent 161ff26b
No related branches found
No related tags found
No related merge requests found
...@@ -116,18 +116,23 @@ class SimpleSAML_Memcache { ...@@ -116,18 +116,23 @@ class SimpleSAML_Memcache {
* *
* @param $key The key of the data. * @param $key The key of the data.
* @param $value The value of the data. * @param $value The value of the data.
* @param int|NULL $expire The expiration timestamp of the data.
*/ */
public static function set($key, $value) { public static function set($key, $value, $expire = NULL) {
$savedInfo = array( $savedInfo = array(
'timestamp' => microtime(TRUE), 'timestamp' => microtime(TRUE),
'data' => $value 'data' => $value
); );
if ($expire === NULL) {
$expire = self::getExpireTime();
}
$savedInfoSerialized = serialize($savedInfo); $savedInfoSerialized = serialize($savedInfo);
/* Store this object to all groups of memcache servers. */ /* Store this object to all groups of memcache servers. */
foreach(self::getMemcacheServers() as $server) { foreach(self::getMemcacheServers() as $server) {
$server->set($key, $savedInfoSerialized, 0, self::getExpireTime()); $server->set($key, $savedInfoSerialized, 0, $expire);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment