Skip to content

Commit

Permalink
Merge pull request #4 from fortrabbit/develop
Browse files Browse the repository at this point in the history
More resilient multiSet
  • Loading branch information
Oliver Stark authored Feb 8, 2021
2 parents a356523 + bec8c07 commit 73a2e8a
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 3 deletions.
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Changelog

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

## [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
```

## [1.0.0]

Initial release
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
1 change: 0 additions & 1 deletion src/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use yii\base\BootstrapInterface;
use yii\base\InvalidConfigException;
use yii\caching\MemCache;

/**
* Class Bootstrap
Expand Down
33 changes: 33 additions & 0 deletions src/MemCache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace fortrabbit\MemcachedEnabler;


class MemCache extends \yii\caching\MemCache
{
/**
* @inheritDoc
*/
protected function setValues($data, $duration)
{
try {
return parent::setValues($data, $duration);
} catch (\ErrorException $exception) {
error_log('MemcachedEnabler: ' . $exception->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;
}
}
}

0 comments on commit 73a2e8a

Please sign in to comment.