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
Closed
Labels
bug A bug report status: medium Medium

Comments

@zsilbi
Copy link
Member

zsilbi 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
@zsilbi
Copy link
Member Author

zsilbi 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
Copy link
Member

niden commented May 21, 2019

Resolved in #14106

@niden niden closed this as completed May 21, 2019
@niden niden added the 4.0 label Jun 21, 2019
@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

2 participants