remove current timestamp prefix from timeout definition

This commit is contained in:
ghost 2023-08-13 12:18:44 +03:00
parent 895a3dd6a2
commit e6903cc640
2 changed files with 11 additions and 11 deletions

View file

@ -10,11 +10,11 @@ Extends [PHP memcached](https://www.php.net/manual/en/book.memcached.php)
``` ```
$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
3600 // cache time offset by default 3600 + time() // cache time by default
); );
``` ```
@ -34,9 +34,9 @@ Return cached or cache new value of plain value callback
``` ```
$value = $memory->getByValueCallback( $value = $memory->getByValueCallback(
'key_name', // string, unique key name 'key_name', // string, unique key name
'value', // mixed, plain value 'value', // mixed, plain value
3600, // optional, cache timeout offset for this value 3600 + time(), // optional, cache timeout for this value
); );
``` ```
@ -53,6 +53,6 @@ Return cached or cache new value of object method callback
$method_attribute_2, $method_attribute_2,
... ...
] ]
3600, // optional, cache timeout offset for this value 3600 + time(), // optional, cache timeout for this value
); );
``` ```

View file

@ -40,7 +40,7 @@ class Memory {
] ]
); );
return $this->_memcached->set($key, $value, ($timeout ? $timeout : $this->_timeout) + time()); return $this->_memcached->set($key, $value, ($timeout ? $timeout : $this->_timeout));
} }
public function delete(string $key) : bool public function delete(string $key) : bool
@ -70,7 +70,7 @@ class Memory {
} }
else else
{ {
if (true === $this->_memcached->set($key, $value, ($timeout ? $timeout : $this->_timeout) + time())) if (true === $this->_memcached->set($key, $value, ($timeout ? $timeout : $this->_timeout)))
{ {
return $value; return $value;
} }
@ -106,7 +106,7 @@ class Memory {
$arguments $arguments
); );
if (true === $this->_memcached->set($key, $value, ($timeout ? $timeout : $this->_timeout) + time())) if (true === $this->_memcached->set($key, $value, ($timeout ? $timeout : $this->_timeout)))
{ {
return $value; return $value;
} }