summaryrefslogtreecommitdiffstats
path: root/application/controllers/test_redis.php
blob: b84c652d7f5d0b3c6f31c5d24d10749e66984f12 (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
<?php
class Test_redis extends CI_Controller
{

    function __construct()
    {
        parent::__construct();

        $this->load->library('unit_test');

        $this->load->driver('cache', array('adapter' => 'redis'));
    }

    function index()
    {
        $this->unit->run($this->cache->redis->is_supported(), 'is_true');

        $this->unit->run($this->cache->redis->save('foo', 'bar'), 'is_true');

        $this->unit->run($this->cache->redis->get('foo'), 'bar');

        $this->unit->run($this->cache->redis->delete('foo'), 'is_true');

        $this->unit->run($this->cache->redis->save('foo', 'bar', 1800), 'is_true');

        $this->unit->run(
            $this->cache->redis->get_metadata('foo'),
            array(
                'data' => 'bar',
                'expire' => time() + 1800
            )
        );

        $this->unit->run($this->cache->redis->clean(), 'is_true');

        $this->unit->run($this->cache->redis->get('foo'), 'is_false');

        $this->unit->run($this->cache->redis->cache_info(), 'is_array');

        echo $this->unit->report();
    }

}