diff --git a/src/DbObject.php b/src/DbObject.php index e8470ec..2548c51 100644 --- a/src/DbObject.php +++ b/src/DbObject.php @@ -53,6 +53,7 @@ abstract class DbObject $this->onAfterSave(); } + // @codeCoverageIgnoreStart /** * Method invoked after loading the object. */ @@ -74,4 +75,5 @@ abstract class DbObject { } + // @codeCoverageIgnoreEnd } diff --git a/src/Internal/Driver/RedisArray.php b/src/Internal/Driver/RedisArray.php index d37210a..fe707aa 100644 --- a/src/Internal/Driver/RedisArray.php +++ b/src/Internal/Driver/RedisArray.php @@ -85,32 +85,16 @@ final class RedisArray extends DriverArray $this->db = self::$connections[$dbKey]; } - /** - * Get redis key name. - */ - private function rKey(string $key): string - { - return $this->config->table.':'.$key; - } - - /** - * Get iterator key. - */ - private function itKey(): string - { - return $this->config->table.':*'; - } - public function set(string|int $key, mixed $value): void { - $this->db->set($this->rKey((string) $key), $this->serializer->serialize($value)); + $this->db->set($this->config->table.':'.(string) $key, $this->serializer->serialize($value)); } - public function get(mixed $key): mixed + public function get(string|int $key): mixed { $key = (string) $key; - $value = $this->db->get($this->rKey($key)); + $value = $this->db->get($this->config->table.':'.$key); if ($value !== null) { /** @var TValue */ @@ -122,7 +106,7 @@ final class RedisArray extends DriverArray public function unset(string|int $key): void { - $this->db->delete($this->rkey((string) $key)); + $this->db->delete($this->config->table.':'.(string) $key); } /** @@ -132,9 +116,9 @@ final class RedisArray extends DriverArray */ public function getIterator(): \Traversable { - $request = $this->db->scan($this->itKey()); + $request = $this->db->scan($this->config->table.':*'); - $len = \strlen($this->rKey('')); + $len = \strlen($this->config->table)+1; foreach ($request as $key) { $sub = \substr($key, $len); if ($this->castToInt) { @@ -153,7 +137,7 @@ final class RedisArray extends DriverArray */ public function count(): int { - return \iterator_count($this->db->scan($this->itKey())); + return \iterator_count($this->db->scan($this->config->table.':*')); } /** @@ -161,7 +145,7 @@ final class RedisArray extends DriverArray */ public function clear(): void { - $request = $this->db->scan($this->itKey()); + $request = $this->db->scan($this->config->table.':*'); $keys = []; foreach ($request as $key) {