diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-06-04 17:42:59 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-06-04 22:24:17 +0200 |
commit | 091b343d5cc2766eb84d49b5f2c3c691b5d41a18 (patch) | |
tree | 51356b66b7a2341d8f271f7842a62ff53f47c228 /lib/cache.php | |
parent | dfc90021cacb5b9da3bf06e705133f18b13df583 (diff) | |
download | nextcloud-server-091b343d5cc2766eb84d49b5f2c3c691b5d41a18.tar.gz nextcloud-server-091b343d5cc2766eb84d49b5f2c3c691b5d41a18.zip |
Calendar & Contacts: Store import progress in OC_Cache
Convert calendar and contacts import to use a caching system
for storing the import progress percentage. OC_Cache can later
be made smarter about storing values.
Diffstat (limited to 'lib/cache.php')
-rw-r--r-- | lib/cache.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/cache.php b/lib/cache.php new file mode 100644 index 00000000000..a4fb2448432 --- /dev/null +++ b/lib/cache.php @@ -0,0 +1,40 @@ +<?php +/** + * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +class OC_Cache { + static protected $cache; + + static protected function init() { + self::$cache = new OC_Cache_File(); + } + + static public function get($key) { + if (!self::$cache) { + self::init(); + } + return self::$cache->get($key); + } + + static public function set($key, $value, $ttl=0) { + if (empty($key)) { + return false; + } + if (!self::$cache) { + self::init(); + } + return self::$cache->set($key, $value, $ttl); + } + + static public function remove($key) { + if (!self::$cache) { + self::init(); + } + return self::$cache->remove($key); + } + +} |