1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Webdcg\Redis\Traits; |
4
|
|
|
|
5
|
|
|
trait Strings |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Append specified string to the string stored in specified key. |
9
|
|
|
* |
10
|
|
|
* @param string $key |
11
|
|
|
* @param string $value |
12
|
|
|
* |
13
|
|
|
* @return int Size of the value after the append. |
14
|
|
|
*/ |
15
|
|
|
public function append(string $key, string $value): int |
16
|
|
|
{ |
17
|
|
|
return $this->redis->append($key, $value); |
|
|
|
|
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function decr(): bool |
21
|
|
|
{ |
22
|
|
|
return false; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function decrBy(): bool |
26
|
|
|
{ |
27
|
|
|
return false; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function get(string $key) |
31
|
|
|
{ |
32
|
|
|
return $this->redis->get($key); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function getRange(): bool |
36
|
|
|
{ |
37
|
|
|
return false; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function getSet(): bool |
41
|
|
|
{ |
42
|
|
|
return false; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function incr(): bool |
46
|
|
|
{ |
47
|
|
|
return false; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function incrBy(): bool |
51
|
|
|
{ |
52
|
|
|
return false; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function incrByFloat(): bool |
56
|
|
|
{ |
57
|
|
|
return false; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function mGet(): bool |
61
|
|
|
{ |
62
|
|
|
return false; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getMultiple(): bool |
66
|
|
|
{ |
67
|
|
|
return false; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function mSet(): bool |
71
|
|
|
{ |
72
|
|
|
return false; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function mSetNX(): bool |
76
|
|
|
{ |
77
|
|
|
return false; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Set the string value in argument as value of the key. If you're using Redis >= 2.6.12, you can pass extended |
82
|
|
|
* options as explained below. |
83
|
|
|
* |
84
|
|
|
* @param string $key |
85
|
|
|
* @param mixed $value |
86
|
|
|
* @param mixed $args Timeout or Options Array (optional). If you pass an |
87
|
|
|
* integer, phpredis will redirect to SETEX, and will |
88
|
|
|
* try to use Redis >= 2.6.12 extended options if you |
89
|
|
|
* pass an array with valid values |
90
|
|
|
* |
91
|
|
|
* @return bool TRUE if the command is successful. |
92
|
|
|
*/ |
93
|
|
|
public function set(string $key, $value, ...$args): bool |
94
|
|
|
{ |
95
|
|
|
if (empty($args)) { |
96
|
|
|
return $this->redis->set($key, $value); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
return $this->redis->set($key, $value, $args[0]); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function setEx(string $key, int $timeout, $value): bool |
103
|
|
|
{ |
104
|
|
|
return $this->redis->setEx($key, $timeout, $value); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function pSetEx(): bool |
108
|
|
|
{ |
109
|
|
|
return false; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function setNx(): bool |
113
|
|
|
{ |
114
|
|
|
return false; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function setRange(): bool |
118
|
|
|
{ |
119
|
|
|
return false; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function strLen(): bool |
123
|
|
|
{ |
124
|
|
|
return false; |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: