Added hasKey() method to OC_Cache.
This commit is contained in:
parent
9dbb07b806
commit
098beae751
2 changed files with 22 additions and 7 deletions
|
@ -30,6 +30,13 @@ class OC_Cache {
|
|||
return self::$cache->set($key, $value, $ttl);
|
||||
}
|
||||
|
||||
static public function hasKey($key) {
|
||||
if (!self::$cache) {
|
||||
self::init();
|
||||
}
|
||||
return self::$cache->hasKey($key);
|
||||
}
|
||||
|
||||
static public function remove($key) {
|
||||
if (!self::$cache) {
|
||||
self::init();
|
||||
|
|
22
lib/cache/file.php
vendored
22
lib/cache/file.php
vendored
|
@ -23,13 +23,8 @@ class OC_Cache_File{
|
|||
}
|
||||
|
||||
public function get($key) {
|
||||
$storage = $this->getStorage();
|
||||
if ($storage and $storage->is_file($key)) {
|
||||
$mtime = $storage->filemtime($key);
|
||||
if ($mtime < time()) {
|
||||
$storage->unlink($key);
|
||||
return null;
|
||||
}
|
||||
if ($this->hasKey($key)) {
|
||||
$storage = $this->getStorage();
|
||||
return $storage->file_get_contents($key);
|
||||
}
|
||||
return null;
|
||||
|
@ -43,6 +38,19 @@ class OC_Cache_File{
|
|||
return false;
|
||||
}
|
||||
|
||||
public function hasKey($key) {
|
||||
$storage = $this->getStorage();
|
||||
if ($storage->is_file($key)) {
|
||||
$mtime = $storage->filemtime($key);
|
||||
if ($mtime < time()) {
|
||||
$storage->unlink($key);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function remove($key) {
|
||||
$storage = $this->getStorage();
|
||||
if(!$storage){
|
||||
|
|
Loading…
Reference in a new issue