| @@ 123-134 (lines=12) @@ | ||
| 120 | /** |
|
| 121 | * {@inheritdoc} |
|
| 122 | */ |
|
| 123 | public function inc(string $name, int $delta = 1): int |
|
| 124 | { |
|
| 125 | $value = $this->get($name, $expiration) + $delta; |
|
| 126 | ||
| 127 | if (empty($expiration)) { |
|
| 128 | $this->set($name, $value); |
|
| 129 | } else { |
|
| 130 | $this->set($name, $value, $expiration - time()); |
|
| 131 | } |
|
| 132 | ||
| 133 | return $value; |
|
| 134 | } |
|
| 135 | ||
| 136 | /** |
|
| 137 | * {@inheritdoc} |
|
| @@ 139-150 (lines=12) @@ | ||
| 136 | /** |
|
| 137 | * {@inheritdoc} |
|
| 138 | */ |
|
| 139 | public function dec(string $name, int $delta = 1): int |
|
| 140 | { |
|
| 141 | $value = $this->get($name, $expiration) - $delta; |
|
| 142 | ||
| 143 | if (empty($expiration)) { |
|
| 144 | $this->set($name, $value); |
|
| 145 | } else { |
|
| 146 | $this->set($name, $value, $expiration - time()); |
|
| 147 | } |
|
| 148 | ||
| 149 | return $value; |
|
| 150 | } |
|
| 151 | ||
| 152 | /** |
|
| 153 | * {@inheritdoc} |
|