Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Cache] Add MemcachedAdapter #20743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[Cache] Fix CS
  • Loading branch information
Babacooll committed Dec 3, 2016
commit 4b685f7db4f0c7a940c1472af248927b765285bb
27 changes: 14 additions & 13 deletions 27 src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ class MemcachedAdapter implements AdapterInterface
{
private $namespaceKey;
private $getCacheItemAsArray;
private $deferredItems = [];
private $deferredItems = array();
private $changeIsHit;
private $namespace;
private $createCacheItem;
private $client;

/**
* @param \Memcached $client
* @param string $namespace
* @param int $defaultLifetime
* @param string $namespace
* @param int $defaultLifetime
*/
public function __construct(\Memcached $client, $namespace = '', $defaultLifetime = 0)
{
$this->client = $client;
$this->namespaceKey = 'symfony_cache_namespace_key_' . $namespace;
$this->namespaceKey = 'symfony_cache_namespace_key_'.$namespace;
$this->namespace = $this->client->get($this->namespaceKey);

if (false === $this->namespace) {
Expand All @@ -62,11 +62,11 @@ function ($key, $value, $isHit) use ($defaultLifetime) {

$this->getCacheItemAsArray = \Closure::bind(
function (CacheItem $item) use ($defaultLifetime) {
return [
return array(
'key' => $item->key,
'value' => $item->value,
'expiry' => $item->expiry !== null ? $item->expiry : $defaultLifetime
];
'expiry' => $item->expiry !== null ? $item->expiry : $defaultLifetime,
);
},
null,
CacheItem::class
Expand Down Expand Up @@ -112,7 +112,7 @@ public function getItem($key)
/**
* {@inheritdoc}
*/
public function getItems(array $keys = [])
public function getItems(array $keys = array())
{
$this->validateKeys($keys);

Expand Down Expand Up @@ -150,7 +150,7 @@ public function hasItem($key)
*/
public function clear()
{
$this->deferredItems = [];
$this->deferredItems = array();

$namespace = $this->client->increment($this->namespaceKey);

Expand Down Expand Up @@ -234,7 +234,7 @@ public function saveDeferred(CacheItemInterface $item)
*/
public function commit()
{
$deferredItemsByExpiry = [];
$deferredItemsByExpiry = array();

foreach ($this->deferredItems as $deferredItem) {
$f = $this->getCacheItemAsArray;
Expand All @@ -247,13 +247,13 @@ public function commit()
$success = $this->client->setMulti($deferredItems, $expiry);

if (false === $success) {
$this->deferredItems = [];
$this->deferredItems = array();

return false;
}
}

$this->deferredItems = [];
$this->deferredItems = array();

return true;
}
Expand All @@ -273,7 +273,7 @@ private function isLastResultHit()
*/
private function addNamespaceToKey($key)
{
return $this->namespace . $key;
return $this->namespace.$key;
}

/**
Expand Down Expand Up @@ -307,6 +307,7 @@ private function validateKeys(array $keys)
/**
* @param array $keys
* @param array $notFoundKeys
*
* @return \Generator
*/
private function generateItems(array $keys, array $notFoundKeys)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public static function setupBeforeClass()

$client = new \Memcached();

$client->addServers([
[$memcachedHost, 11211],
]);
$client->addServers(array(
array($memcachedHost, 11211),
));

static::$memcachedClient = $client;
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.