Skip to content
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

Cache\Adapter\Libmemcached::set() is not working under special circumstances #14100

Closed
zsilbi opened this issue May 20, 2019 · 2 comments

Comments

@zsilbi
Copy link
Contributor

commented May 20, 2019

$cache->set() is not working when Libmemcached is used at the same time for cache and modelsMetadata.

class Robots extends \Phalcon\Mvc\Model {}

$di->setShared(
    'cache',
    function () {
        return new \Phalcon\Cache\Cache(
            new \Phalcon\Cache\Adapter\Libmemcached(
                new \Phalcon\Storage\SerializerFactory(),
                [
                    'servers' => [
                        [
                            'host' => 'my-host',
                            'port' => 11211
                        ]
                    ],
                    'prefix'  => 'my-cache-prefix'
                ]
            )
        );
    }
);

$di->setShared(
    'modelsMetadata',
    function () {
        return new \Phalcon\Mvc\Model\MetaData\Libmemcached(
            new \Phalcon\Cache\AdapterFactory(
                new \Phalcon\Storage\SerializerFactory()
            ),
            [
                'servers' => [
                    [
                        'host' => 'my-host',
                        'port' => 11211
                    ]
                ],
                'prefix'  => 'my-metadata-prefix'
            ]
        );
    }
);

Provide minimal script to reproduce the issue

$cache = $di->getShared('cache');

var_dump($cache->get('my-test-key')); // NULL

$testData = ['my-test-data'];

Robots::findFirst();

var_dump($cache->set('my-test-key', $testData)); // bool(true)

This script should run more than once, of course.

$cache->set() always returns true, but fails to save the test data.

It works:

  • When MetaData cache is not used
  • If Robots::findFirst() is called before $cache->get()
  • Without Robots::findFirst()
  • Without $cache->get()

Details

  • Phalcon version: 4.0.0-alpha.5
  • PHP Version: 7.3.4
  • Operating System: Ubuntu 16.04
  • Installation type: Compiling from source
  • Zephir version: Version 0.12.0 (from the development branch)
  • Server: nginx

@niden niden added this to To do in 4.0 Release via automation May 20, 2019

@niden niden added the Bug - Medium label May 20, 2019

@zsilbi

This comment has been minimized.

Copy link
Contributor Author

commented May 20, 2019

The problem is, that two Memached instances are running at the same time using "persistent" connections with same persistentId option set. I am sending a PR to correct this.

@niden

This comment has been minimized.

Copy link
Member

commented May 21, 2019

Resolved in #14106

@niden niden closed this May 21, 2019

4.0 Release automation moved this from To do to Done May 21, 2019

@niden niden added the 4.0 label Jun 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
2 participants
You can’t perform that action at this time.