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/phplib/CT_Cache.php | |
| parent | da0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff) | |
| parent | 97a188592c679890a25c37ab78463add76a52ff7 (diff) | |
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'lib/phplib/CT_Cache.php')
| -rw-r--r-- | lib/phplib/CT_Cache.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/phplib/CT_Cache.php b/lib/phplib/CT_Cache.php new file mode 100644 index 0000000..d4eccfa --- /dev/null +++ b/lib/phplib/CT_Cache.php @@ -0,0 +1,68 @@ +<?php + +## Copyright (c) 2011 Elmar Ludwig, University of Osnabrueck +## +## PHPLIB Data Storage Container using Stud.IP cache +## for use with Stud.IP and cache only! + +class CT_Cache +{ + protected const CACHE_KEY_PREFIX = 'session_data'; + protected const SESSION_LIFETIME = 7200; + + private $cache; + + public function ac_start() + { + $this->cache = \Studip\Cache\Factory::getCache(); + } + + public function ac_get_lock() + { + } + + public function ac_release_lock() + { + } + + public function ac_newid($str, $name = null) + { + return $this->ac_get_value($str) === false ? $str : false; + } + + public function ac_store($id, $name, $str) + { + $cache_key = self::CACHE_KEY_PREFIX . '/' . $id; + return $this->cache->write($cache_key, $str, ini_get('session.gc_maxlifetime') ?: self::SESSION_LIFETIME); + } + + public function ac_delete($id, $name = null) + { + $cache_key = self::CACHE_KEY_PREFIX . '/' . $id; + $this->cache->expire($cache_key); + } + + public function ac_gc($gc_time, $name = null) + { + } + + public function ac_halt($s) + { + echo "<b>$s</b>"; + exit; + } + + public function ac_get_value($id, $name = null) + { + $cache_key = self::CACHE_KEY_PREFIX . '/' . $id; + return $this->cache->read($cache_key); + } + + public function ac_get_changed($id, $name = null) + { + } + + public function ac_set_changed($id, $name, $timestamp) + { + } +} |
