Store modelsMetadata in other cache service exclude memcache (memcache != memcached)
HI every body . I used long time phalcon 2.x.x + memcache (no memcached) + beanstalkd. Have a 3 services for cache : 'modelsMetadata', 'modelsCache' and 'cache' for other manual store data.
modelsCache and cache - working good on php7 + phalcon 3 But cahce for modelsMetadata have a problem
I installed phalcon3.0.3 + php 7.0.13 without memcache (7.1 not supported phalcon at now) and testing on macos + mamp4
old used:
\Phalcon\Cache\Backend\Memcache($frontCache, $config->memcache); - used memcahce.
Now need use memcacheD !
try use Libmemcached:
for example use cached modelsMetadata:
$di->setShared('modelsMetadata', function () use ($config) {
$frontCache = new \Phalcon\Cache\Frontend\Data([
"lifetime" => 3600,
]);
return new \Phalcon\Cache\Backend\Libmemcached($frontCache, $config->memcached);
});
errors:
Call to undefined method Phalcon\Cache\Backend\Libmemcached::hasattribute()
Call to undefined method ::hasattribute()
try Redis
return new \Phalcon\Cache\Backend\Redis($frontCache, $config->redis);
some error:
Call to undefined method Phalcon\Cache\Backend\Redis::hasattribute()
Call to undefined method ::hasattribute()
try Apc
new \Phalcon\Cache\Backend\Apc($frontCache);
error:
Call to undefined method ::hasattribute()
try :
return new \Phalcon\Mvc\Model\MetaData\Apc([
"prefix" => "mm",
"lifetime" => 86400,
]);
error:
Call to undefined function apc_fetch()
if turnoff modelsMetadata - working, but before all sql, run DESCRIBE table ...
How use modelsMetadata cache without memcache ?
Details
- Phalcon version: 3.0.3
- PHP Version: 7.0.13
- Operating System: maxos + mamp4 for test, ubuntu stage
- Installation type: Compiling from source || installing via package manager
- Zephir version (if any):
- Server: Apache for macos (mamp4) Nginx - on stage ubuntu
- Other related info : mysql 5.6.34 innodb
Metadata has his own adapter in Phalcon/Mvc/Model/Metadata which you should use https://github.com/phalcon/cphalcon/tree/master/phalcon/mvc/model/metadata. Not backend cache
Metadata has his own adapter in Phalcon/Mvc/Model/Metadata which you should use https://github.com/phalcon/cphalcon/tree/master/phalcon/mvc/model/metadata. Not backend cache
I tried
$di->setShared('modelsMetadata', function () use ($config) {
$frontCache = new \Phalcon\Cache\Frontend\Data([
"lifetime" => 3600,
]);
return new \Phalcon\Cache\Backend\Libmemcached($frontCache, $config->memcached);
});
Same problem Call to undefined method ::hasattribute()
For \Phalcon\Cache\Backend\Redis and\Phalcon\Cache\Backend\Apc
same fail
Where you tried? Don't see. You still have \Phalcon\Cache\Backend\Libmemcached. You should use \Phalcon\Mvc\Model\Metadata\Libmemcached
Sorry. It has already work! Thanks !
$di->setShared('modelsMetadata', function () use ($config) {
return new \Phalcon\Mvc\Model\MetaData\Libmemcached(array_merge($config->memcached->toArray(), [
'client' => array(
Memcached::OPT_HASH => Memcached::HASH_MD5,
Memcached::OPT_PREFIX_KEY => 'prefix.',
),
'lifetime' => 3600,
'prefix' => 'mm'
]));
});