Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 1 | <?php |
| 2 | class Test_redis extends CI_Controller |
| 3 | { |
| 4 | |
| 5 | function __construct() |
| 6 | { |
| 7 | parent::__construct(); |
| 8 | |
| 9 | $this->load->library('unit_test'); |
| 10 | |
| 11 | $this->load->driver('cache', array('adapter' => 'redis')); |
| 12 | } |
| 13 | |
| 14 | function index() |
| 15 | { |
| 16 | $this->unit->run($this->cache->redis->is_supported(), 'is_true'); |
| 17 | |
| 18 | $this->unit->run($this->cache->redis->save('foo', 'bar'), 'is_true'); |
| 19 | |
| 20 | $this->unit->run($this->cache->redis->get('foo'), 'bar'); |
| 21 | |
| 22 | $this->unit->run($this->cache->redis->delete('foo'), 'is_true'); |
| 23 | |
| 24 | $this->unit->run($this->cache->redis->save('foo', 'bar', 1800), 'is_true'); |
| 25 | |
| 26 | $this->unit->run( |
| 27 | $this->cache->redis->get_metadata('foo'), |
| 28 | array( |
| 29 | 'data' => 'bar', |
| 30 | 'expire' => time() + 1800 |
| 31 | ) |
| 32 | ); |
| 33 | |
| 34 | $this->unit->run($this->cache->redis->clean(), 'is_true'); |
| 35 | |
| 36 | $this->unit->run($this->cache->redis->get('foo'), 'is_false'); |
| 37 | |
| 38 | $this->unit->run($this->cache->redis->cache_info(), 'is_array'); |
| 39 | |
| 40 | echo $this->unit->report(); |
| 41 | } |
| 42 | |
| 43 | } |