-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRedisRepository.php
45 lines (37 loc) · 1014 Bytes
/
RedisRepository.php
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
<?php namespace Devtools;
use Redis;
class RedisRepository
{
public function __construct(Redis $connection)
{
$this->connection = $connection;
}
public function get($key, $collection = null)
{
return is_null($collection) ?
$this->connection->get($key) :
$this->connection->hget($collection, $key);
}
public function getAll($collection)
{
return $this->connection->hgetall($collection);
}
public function set($key, $value, $collection=null)
{
return is_null($collection) ?
$this->connection->set($key, $value) :
$this->connection->hset($collection, $key, $value);
}
public function query($key, $collection=null)
{
return $this->get($key, $collection);
}
public static function sanitize($queryString)
{
return $queryString;
}
public function expire($key, $expiry)
{
return $this->connection->expire($key, $expiry);
}
}