Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/cache
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-06-05 22:21:06 +0400
committerThomas Tanghus <thomas@tanghus.net>2012-06-05 22:34:12 +0400
commit098beae751e5bf5995d3afc5b01ed6ca67676f64 (patch)
tree9fcbdbc7a2a370a6f820995d210acb365effcfee /lib/cache
parent9dbb07b806c3795d1910f6998c644977d06746e2 (diff)
Added hasKey() method to OC_Cache.
Diffstat (limited to 'lib/cache')
-rw-r--r--lib/cache/file.php22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/cache/file.php b/lib/cache/file.php
index 1c97c5be4e2..348389e9ff4 100644
--- a/lib/cache/file.php
+++ b/lib/cache/file.php
@@ -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){