aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/StudipMemoryCache.class.php
diff options
context:
space:
mode:
authorPhilipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de>2024-09-24 10:53:31 +0200
committerPhilipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de>2024-09-24 10:53:31 +0200
commit4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch)
tree5c07151ae61276d334e88f6309c30d439a85c12e /lib/classes/StudipMemoryCache.class.php
parentda0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff)
parent97a188592c679890a25c37ab78463add76a52ff7 (diff)
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'lib/classes/StudipMemoryCache.class.php')
-rw-r--r--lib/classes/StudipMemoryCache.class.php84
1 files changed, 0 insertions, 84 deletions
diff --git a/lib/classes/StudipMemoryCache.class.php b/lib/classes/StudipMemoryCache.class.php
deleted file mode 100644
index d38385a..0000000
--- a/lib/classes/StudipMemoryCache.class.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-/**
- * The php memory implementation of the StudipCache interface.
- *
- * @author Jan-Hendrik Willms <tleilax+studip@gmail.com>
- * @license GPL2 or any later version
- * @since Stud.IP 5.0
- */
-class StudipMemoryCache implements StudipCache
-{
- protected $memory_cache = [];
-
- /**
- * Expires just a single key.
- *
- * @param string the key
- */
- public function expire($key)
- {
- unset($this->memory_cache[$key]);
- }
-
- /**
- * Expire all items from the cache.
- */
- public function flush()
- {
- $this->memory_cache = [];
- }
-
- /**
- * Reads just a single key from the cache.
- *
- * @param string the key
- *
- * @return mixed the corresponding value
- */
- public function read($key)
- {
- if (!isset($this->memory_cache[$key])) {
- return false;
- }
- if ($this->memory_cache[$key]['expires'] < time()) {
- $this->expire($key);
- return false;
- }
- return $this->memory_cache[$key]['data'];
- }
-
- /**
- * Store data at the server.
- *
- * @param string the item's key.
- * @param mixed the item's content (will be serialized if necessary).
- * @param int the item's expiry time in seconds. Defaults to 12h.
- *
- * @returns mixed returns TRUE on success or FALSE on failure.
- *
- */
- public function write($name, $content, $expires = self::DEFAULT_EXPIRATION)
- {
- $this->memory_cache[$name] = [
- 'expires' => time() + $expires,
- 'data' => $content,
- ];
-
- return true;
- }
-
- public static function getDisplayName(): string
- {
- return 'Memory cache';
- }
-
- public function getStats(): array
- {
- return [];
- }
-
- public static function getConfig(): array
- {
- return [];
- }
-}