@@ -27,7 +27,8 @@ discard block |
||
| 27 | 27 | { |
| 28 | 28 | $value = $this->storage->get($this->resolveKey($key)); |
| 29 | 29 | |
| 30 | - if ($value === null) { |
|
| 30 | + if ($value === null) |
|
| 31 | + { |
|
| 31 | 32 | $this->dispatcher?->dispatch(new CacheMissed($this->resolveKey($key))); |
| 32 | 33 | |
| 33 | 34 | return $default; |
@@ -42,7 +43,8 @@ discard block |
||
| 42 | 43 | { |
| 43 | 44 | $result = $this->storage->set($this->resolveKey($key), $value, $ttl); |
| 44 | 45 | |
| 45 | - if ($result) { |
|
| 46 | + if ($result) |
|
| 47 | + { |
|
| 46 | 48 | $this->dispatcher?->dispatch(new KeyWritten($this->resolveKey($key), $value)); |
| 47 | 49 | } |
| 48 | 50 | |
@@ -53,7 +55,8 @@ discard block |
||
| 53 | 55 | { |
| 54 | 56 | $result = $this->storage->delete($this->resolveKey($key)); |
| 55 | 57 | |
| 56 | - if ($result) { |
|
| 58 | + if ($result) |
|
| 59 | + { |
|
| 57 | 60 | $this->dispatcher?->dispatch(new KeyDeleted($this->resolveKey($key))); |
| 58 | 61 | } |
| 59 | 62 | |
@@ -69,7 +72,8 @@ discard block |
||
| 69 | 72 | { |
| 70 | 73 | $result = []; |
| 71 | 74 | |
| 72 | - foreach ($keys as $key) { |
|
| 75 | + foreach ($keys as $key) |
|
| 76 | + { |
|
| 73 | 77 | $result[$key] = $this->get($key, $default); |
| 74 | 78 | } |
| 75 | 79 | |
@@ -80,7 +84,8 @@ discard block |
||
| 80 | 84 | { |
| 81 | 85 | $state = null; |
| 82 | 86 | |
| 83 | - foreach ($values as $key => $value) { |
|
| 87 | + foreach ($values as $key => $value) |
|
| 88 | + { |
|
| 84 | 89 | $result = $this->set($key, $value, $ttl); |
| 85 | 90 | $state = \is_null($state) ? $result : $result && $state; |
| 86 | 91 | } |
@@ -91,7 +96,8 @@ discard block |
||
| 91 | 96 | public function deleteMultiple(iterable $keys): bool |
| 92 | 97 | { |
| 93 | 98 | $state = null; |
| 94 | - foreach ($keys as $key) { |
|
| 99 | + foreach ($keys as $key) |
|
| 100 | + { |
|
| 95 | 101 | $result = $this->delete($key); |
| 96 | 102 | $state = \is_null($state) ? $result : $result && $state; |
| 97 | 103 | } |
@@ -111,7 +117,8 @@ discard block |
||
| 111 | 117 | |
| 112 | 118 | private function resolveKey(string $key): string |
| 113 | 119 | { |
| 114 | - if (!empty($this->prefix)) { |
|
| 120 | + if (!empty($this->prefix)) |
|
| 121 | + { |
|
| 115 | 122 | return $this->prefix . $key; |
| 116 | 123 | } |
| 117 | 124 | |
@@ -30,12 +30,14 @@ |
||
| 30 | 30 | $storage = $this->config->getAliases()[$name] ?? $name; |
| 31 | 31 | |
| 32 | 32 | $prefix = null; |
| 33 | - if (\is_array($storage)) { |
|
| 33 | + if (\is_array($storage)) |
|
| 34 | + { |
|
| 34 | 35 | $prefix = !empty($storage['prefix']) ? $storage['prefix'] : null; |
| 35 | 36 | $storage = $storage['storage']; |
| 36 | 37 | } |
| 37 | 38 | |
| 38 | - if (!isset($this->storages[$storage])) { |
|
| 39 | + if (!isset($this->storages[$storage])) |
|
| 40 | + { |
|
| 39 | 41 | $this->storages[$storage] = $this->resolve($storage); |
| 40 | 42 | } |
| 41 | 43 | |