aboutsummaryrefslogtreecommitdiff
path: root/lib/phplib/CT_Cache.class.php
blob: 311b27cba5526c1ea3203b1ae973f29806f0d6f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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 = StudipCacheFactory::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)
    {
    }
}