From e6903cc64086594d9d18b1699781b56ecb58e72f Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 13 Aug 2023 12:18:44 +0300 Subject: [PATCH] remove current timestamp prefix from timeout definition --- README.md | 16 ++++++++-------- src/Memory.php | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 52d349c..23e1c6b 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,11 @@ Extends [PHP memcached](https://www.php.net/manual/en/book.memcached.php) ``` $memory = new Yggverse\Cache\Memory( - 'localhost, // memcached server host, localhost by default - 11211, // memcached server port, 11211 by default + 'localhost, // memcached server host, localhost by default + 11211, // memcached server port, 11211 by default - 'my_app', // application namespace - 3600 // cache time offset by default + 'my_app', // application namespace + 3600 + time() // cache time by default ); ``` @@ -34,9 +34,9 @@ Return cached or cache new value of plain value callback ``` $value = $memory->getByValueCallback( - 'key_name', // string, unique key name - 'value', // mixed, plain value - 3600, // optional, cache timeout offset for this value + 'key_name', // string, unique key name + 'value', // mixed, plain 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, ... ] - 3600, // optional, cache timeout offset for this value + 3600 + time(), // optional, cache timeout for this value ); ``` \ No newline at end of file diff --git a/src/Memory.php b/src/Memory.php index 5f06f29..38d93f8 100644 --- a/src/Memory.php +++ b/src/Memory.php @@ -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 @@ -70,7 +70,7 @@ class Memory { } 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; } @@ -106,7 +106,7 @@ class Memory { $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; }