From 4c37b6daf10b6bdbb142e1c7b7dd018e2edd2212 Mon Sep 17 00:00:00 2001 From: Oliver Stark Date: Mon, 8 Feb 2021 13:49:29 +0100 Subject: [PATCH 1/2] Catch exceptions when for setValues() --- CHANGELOG.md | 31 +++++++++++++++++++++++++++++++ composer.json | 2 -- src/Bootstrap.php | 1 - src/MemCache.php | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 src/MemCache.php diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..400542e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,31 @@ + +## v1.2.0 + + +## v1.1.1 + +Prevent warning Memcached::addServer() expects parameter 2 to be int, string given, thanks @joshuabaker + +## v1.1.0 +@ostark ostark released this on 18 Oct 2019 + +Added fault-tolerant multi-server support 🎉 +by applying the following options: + +Redundancy + +Memcached::OPT_REMOVE_FAILED_SERVERS: true +Memcached::OPT_RETRY_TIMEOUT: 2 +Memcached::OPT_LIBKETAMA_COMPATIBLE: true +Memcached::OPT_NUMBER_OF_REPLICAS: 1 +Timeouts + +Memcached::OPT_POLL_TIMEOUT: 50 ms +Memcached::OPT_SEND_TIMEOUT: 50 ms +Memcached::OPT_RECV_TIMEOUT: 50 ms +Memcached::OPT_CONNECT_TIMEOUT: 50 ms + + +## v1.0.0 + +Initial release diff --git a/composer.json b/composer.json index 901553a..4fc64c2 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,7 @@ { "name": "fortrabbit/yii-memcached", "description": "Memcached Session & Cache for Craft3 / Yii2 on fortrabbit", - "version": "1.1.1", "type": "yii2-extension", - "keywords": ["yii2", "craftcms", "caching", "cache", "memcached", "memcache", "session"], "license": "MIT", "authors": [ diff --git a/src/Bootstrap.php b/src/Bootstrap.php index 10c2f6f..d3bd64b 100644 --- a/src/Bootstrap.php +++ b/src/Bootstrap.php @@ -4,7 +4,6 @@ use yii\base\BootstrapInterface; use yii\base\InvalidConfigException; -use yii\caching\MemCache; /** * Class Bootstrap diff --git a/src/MemCache.php b/src/MemCache.php new file mode 100644 index 0000000..eedc187 --- /dev/null +++ b/src/MemCache.php @@ -0,0 +1,33 @@ +getMessage()); + return array_keys($data); + } + } + + /** + * @inheritDoc + */ + protected function setValue($key, $value, $duration) + { + try { + return parent::setValue($key, $value, $duration); + } catch (\ErrorException $exception) { + error_log('MemcachedEnabler: ' . $exception->getMessage()); + return false; + } + } +} From bec8c072ca9c51d33a59b84adb4c1b68786995f3 Mon Sep 17 00:00:00 2001 From: Oliver Stark Date: Mon, 8 Feb 2021 21:05:05 +0100 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 400542e..b4d4176 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,31 +1,36 @@ +# Changelog -## v1.2.0 +All notable changes to this project will be documented in this file. +## [1.2.0] - 2021-02-08 +- added `fortrabbit\MemcachedEnabler\MemCache` class +- wrapped `setValues()` and `setValue()` in a try / catch -## v1.1.1 - -Prevent warning Memcached::addServer() expects parameter 2 to be int, string given, thanks @joshuabaker - -## v1.1.0 -@ostark ostark released this on 18 Oct 2019 +## [1.1.1] - 2021-01-27 +Prevent warning `Memcached::addServer()` expects parameter 2 to be int, string given, thanks @joshuabaker +## [1.1.0] - 2019-10-18 Added fault-tolerant multi-server support 🎉 by applying the following options: Redundancy +``` Memcached::OPT_REMOVE_FAILED_SERVERS: true Memcached::OPT_RETRY_TIMEOUT: 2 Memcached::OPT_LIBKETAMA_COMPATIBLE: true Memcached::OPT_NUMBER_OF_REPLICAS: 1 +``` + Timeouts +``` Memcached::OPT_POLL_TIMEOUT: 50 ms Memcached::OPT_SEND_TIMEOUT: 50 ms Memcached::OPT_RECV_TIMEOUT: 50 ms Memcached::OPT_CONNECT_TIMEOUT: 50 ms - +``` -## v1.0.0 +## [1.0.0] Initial release