diff options
| author | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
|---|---|---|
| committer | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
| commit | 4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch) | |
| tree | 5c07151ae61276d334e88f6309c30d439a85c12e /lib/classes/StudipDbCache.class.php | |
| parent | da0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff) | |
| parent | 97a188592c679890a25c37ab78463add76a52ff7 (diff) | |
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'lib/classes/StudipDbCache.class.php')
| -rw-r--r-- | lib/classes/StudipDbCache.class.php | 123 |
1 files changed, 0 insertions, 123 deletions
diff --git a/lib/classes/StudipDbCache.class.php b/lib/classes/StudipDbCache.class.php deleted file mode 100644 index 865825e..0000000 --- a/lib/classes/StudipDbCache.class.php +++ /dev/null @@ -1,123 +0,0 @@ -<?php -/** - * StudipCache implementation using database table - * - * @package studip - * @subpackage cache - * - * @author Elmar Ludwig <elmar.ludwig@uos.de> - */ -class StudipDbCache implements StudipCache -{ - - /** - * @return string A translateable display name for this cache class. - */ - public static function getDisplayName(): string - { - return _('Datenbank'); - } - - /** - * Expire item from the cache. - * - * @param string $arg a single key - */ - public function expire($arg) - { - $db = DBManager::get(); - - $stmt = $db->prepare('DELETE FROM cache WHERE cache_key = ?'); - $stmt->execute([$arg]); - } - - /** - * Expire all items from the cache. - */ - public function flush() - { - $db = DBManager::get(); - - $db->exec('TRUNCATE TABLE cache'); - } - - /** - * Delete all expired items from the cache. - */ - public function purge() - { - $db = DBManager::get(); - - $stmt = $db->prepare('DELETE FROM cache WHERE expires < ?'); - $stmt->execute([time()]); - } - - /** - * Retrieve item from the server. - * - * @param string $arg a single key - * - * @return mixed the previously stored data if an item with such a key - * exists on the server or FALSE on failure. - */ - public function read($arg) - { - $db = DBManager::get(); - - $stmt = $db->prepare('SELECT content FROM cache WHERE cache_key = ? AND expires > ?'); - $stmt->execute([$arg, time()]); - $result = $stmt->fetchColumn(); - - return $result !== false ? unserialize($result) : false; - } - - /** - * Store data at the server. - * - * @param string $name the item's key. - * @param mixed $content the item's content (will be serialized if necessary). - * @param int $expired the item's expiry time in seconds. Optional, defaults to 12h. - * - * @return bool returns TRUE on success or FALSE on failure. - */ - public function write($name, $content, $expires = self::DEFAULT_EXPIRATION) - { - $db = DBManager::get(); - - $stmt = $db->prepare('REPLACE INTO cache VALUES(?, ?, ?)'); - return $stmt->execute([$name, serialize($content), time() + $expires]); - } - - /** - * Return statistics. - * - * @see StudipCache::getStats() - * - * @return array|array[] - */ - public function getStats(): array - { - return [ - __CLASS__ => [ - 'name' => _('Anzahl Einträge'), - 'value' => DBManager::get()->fetchColumn("SELECT COUNT(*) FROM `cache`") - ] - ]; - } - - /** - * Return the Vue component name and props that handle configuration. - * - * @see StudipCache::getConfig() - * - * @return array - */ - public static function getConfig(): array - { - return [ - 'component' => null, - 'props' => [] - ]; - } - -} |
