Skip to content

Commit

Permalink
Merge pull request #64 from sdkawata/add_memcache_expire
Browse files Browse the repository at this point in the history
memcacheの値を設定するときにexpireを指定できるようにする
  • Loading branch information
d9magai authored Jul 2, 2019
2 parents 427857e + 58b338b commit 5f8d48d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Plugin/Cachemanager/Memcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,10 @@ public function isCached($key, $lifetime = null, $namespace = null)
* @param string $key キャッシュキー
* @param mixed $value キャッシュ値
* @param int $timestamp キャッシュ最終更新時刻(unixtime)
* @param int $expire カッシュの有効期限(秒数 0の場合有効期限なし)
* @param string $namespace キャッシュネームスペース
*/
public function set($key, $value, $timestamp = null, $namespace = null)
public function set($key, $value, $timestamp = null, $namespace = null, $expire = 0)
{
$this->_getMemcache($key, $namespace);
if ($this->memcache == null) {
Expand All @@ -243,7 +244,7 @@ public function set($key, $value, $timestamp = null, $namespace = null)
}

$time = $timestamp ? $timestamp : time();
$this->memcache->set($cache_key, array('time' => $time, 'data' => $value), $this->compress ? MEMCACHE_COMPRESSED : null);
$this->memcache->set($cache_key, array('time' => $time, 'data' => $value), $this->compress ? MEMCACHE_COMPRESSED : null, $expire);
}

/**
Expand Down

0 comments on commit 5f8d48d

Please sign in to comment.