summaryrefslogtreecommitdiff
path: root/tests/service/redis.php
blob: d9b77783a83af1225adaa9d70d843bcc7949fc56 (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
<?php

$data = [
    'test' => ['Redis', 'is', 'working'],
    'redis' => '!!'
];

try {

    $redis = new \Predis\Client([
        'host' => 'redis'
    ]);

    foreach($data as $key => $value) {
        echo $key .' ';
        $redis->set( $key, serialize($value), 'EX', 60 );
    }
    echo "...\n\n";

} catch (Exception $e) { 
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}

$test = unserialize($redis->get('test'));
$redis = unserialize($redis->get('redis'));

echo implode(' ', $test) . $redis;