Compare commits

..

No commits in common. "main" and "0.3.0" have entirely different histories.
main ... 0.3.0

2 changed files with 9 additions and 11 deletions

View file

@ -8,9 +8,9 @@ Extends [PHP memcached](https://www.php.net/manual/en/book.memcached.php)
#### Init #### Init
``` ```
$memory = new \Yggverse\Cache\Memory( $memory = new Yggverse\Cache\Memory(
'localhost', // memcached server host, localhost by default 'localhost, // memcached server host, localhost by default
11211, // memcached server port, 11211 by default 11211, // memcached server port, 11211 by default
'my_app', // application namespace 'my_app', // application namespace

View file

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Yggverse\Cache; namespace YGGverse\Cache;
class Memory { class Memory {
@ -19,7 +19,7 @@ class Memory {
$this->_timeout = $timeout; $this->_timeout = $timeout;
} }
public function get(mixed $key) : mixed public function get(string $key) : mixed
{ {
$key = $this->_setKey( $key = $this->_setKey(
[ [
@ -31,7 +31,7 @@ class Memory {
return $this->_memcached->get($key); return $this->_memcached->get($key);
} }
public function set(mixed $key, mixed $value = null, int $timeout = null) : bool public function set(string $key, mixed $value = null, int $timeout = null) : bool
{ {
$key = $this->_setKey( $key = $this->_setKey(
[ [
@ -43,7 +43,7 @@ class Memory {
return $this->_memcached->set($key, $value, ($timeout ? $timeout : $this->_timeout)); return $this->_memcached->set($key, $value, ($timeout ? $timeout : $this->_timeout));
} }
public function delete(mixed $key) : bool public function delete(string $key) : bool
{ {
$key = $this->_setKey( $key = $this->_setKey(
[ [
@ -55,7 +55,7 @@ class Memory {
return $this->_memcached->delete($key); return $this->_memcached->delete($key);
} }
public function getByValueCallback(mixed $key, mixed $value = null, int $timeout = null) : mixed public function getByValueCallback(string $key, mixed $value = null, int $timeout = null) : mixed
{ {
$key = $this->_setKey( $key = $this->_setKey(
[ [
@ -117,11 +117,9 @@ class Memory {
} }
} }
public function flush(?int $delay = 0) : bool public function flush(int $delay = 60) : bool
{ {
return $this->_memcached->flush( return $this->_memcached->flush();
$delay
);
} }
private function _setKey(mixed $key) : string private function _setKey(mixed $key) : string