diff --git a/src/PdoCacheMemcached.php b/src/PdoCacheMemcached.php index fdab4ee..6641738 100644 --- a/src/PdoCacheMemcached.php +++ b/src/PdoCacheMemcached.php @@ -61,7 +61,9 @@ public function scanAndClean( string $key ): array { foreach ( $keys as $key ) { $results[] = $this->read( $key ); } - $this->memcached->deleteMulti( $keys ); + if ( $keys ) { + $this->memcached->deleteMulti( $keys ); + } } return $results; @@ -73,7 +75,7 @@ public function write( string $key, $data ): bool { } $this->setKeysArray( $key ); - return (bool) $this->memcached->set( $this->prefixKey( $key), gzdeflate( serialize( $data ) ), $this->cacheTime ); + return (bool) $this->memcached->set( $this->prefixKey( $key ), gzdeflate( serialize( $data ) ), $this->cacheTime ); } /** @@ -89,14 +91,14 @@ protected function setKeysArray( $key ) { if ( $i == count( $keySplit ) ) { $partKey .= $delimiter; } - $existingKeys = $this->memcached->get( $this->prefixKey( $partKey )); + $existingKeys = $this->memcached->get( $this->prefixKey( $partKey ) ); if ( ! is_array( $existingKeys ) ) { $existingKeys = []; } $existingKeys[] = $key; - $this->memcached->set( $this->prefixKey( $partKey), array_unique( $existingKeys ), $this->cacheTime ); + $this->memcached->set( $this->prefixKey( $partKey ), array_unique( $existingKeys ), $this->cacheTime ); } }; $splitKey( explode( '-', $key ), '-', $key );