Check if memcached is installed? - php

I used this guide to install memcached on Centos 6.5
I first checked
/etc/init.d/memcached status and
memcached (pid 14784) is running...
Then restarted
service httpd restart
But when I try to use memcached on software(prosper202) I get
Fatal error: Call to a member function getCapabilities() on a non-object in /var/zpanel/hostdata/zadmin/public_html/******_com/3rd-parties/wurfl/WURFL/CustomDeviceRepository.php on line 72
I don't know whats causing it.
Here is my WURFL configuration file
<?php
include($_SERVER['DOCUMENT_ROOT'] . '/202-config.php');
$configuration = array(
// WURFL File Configuration
'wurfl' => array(
'main-file' => 'wurfl.zip',
'patches' => array("web_browsers_patch.xml"),
),
// Persistence (Long-Term Storage) Configuration
'persistence' => array(
'provider' => 'mysql',
'params' => array('host'=>$dbhost,
'port'=>3306,
'db'=>$dbname,
'user'=>$dbuser,
'pass'=>$dbpass),
),
// Cache (Short-Term Storage) Configuration
'cache' => array(
'provider' => 'memcache',
'params' => 'host='.$mchost.',port=11211,namespace=wurfl',
),
);

Aha! Your issue is not with your installation of memcached. Keep in mind that memcache and memcached are two different caching mechanisms.
You'll want to make sure that your server has memcache or apc installed for WURFL to be able to cache properly.

Type the following to see if memcached exists:
which memcached
Check the memcached version:
memcached -h

Related

Nextcloud not connecting to Redis

On a Nextcloud install I am receiving the error
No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the documentation.
So I have installed APCu, Redis, redis-php and made the required settings in NCs config.php
'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',
'memcache.distributed' => '\OC\Memcache\Redis',
'filelocking.enabled' => 'true',
'redis' =>
array (
'host' => '127.0.0.1',
'port' => '6379',
When I test the redis connection
redis-cli ping
I get a
PONG
(This works both w/ localhost and unix socket)
But Nextcloud obviously does not connect to Redis.
The http user is a member of the redis group.
php-redis module is activated.
Solved. The issue was with the location of the above code inside Nextcloud's config.php.
Now it is working as expected.

Zendframework 2 with memcache not working

I am trying to get memcache to work with Zendframework 2. How do I get Zendframework 2 to see memcache correct so I don't get the error I have listed below? I want to use memcache instead of memcached.
Error:
Exception - An abstract factory could not create an instance of memcache(alias: memcache).
Previous exceptions - An exception was raised while creating "memcache"; no instance returned
The option "liboptions" does not have a matching setLiboptions setter method which must be defined
I get this error when just trying to test it with this line in a controller
echo $this->getServiceLocator()->get('memcache')->getVersion();
Details:
I'm running windows 7 64 bit with a local instance of IIS7 up and running.
I used this guide to install memecache on my pc: How to Install Memcache on Windows 7
I verified the memcache service is up and running
I verified that using memecache outside of Zendframework 2 works.
So next I followed this guide to get it to work in Zendframework 2: How to setup Zendframework 2 to use Memcached I know this guide is for memcached and not memcache but I used it as a base
Troubleshooting I've done already:
Verified service is running
Verified phpinfo() shows the memcache section so I know the php extension is loading from the php.ini
Since I'm still hazy on memcache vs memcached I've tried setting the config files and above echo to try and use the string
'memcached' and 'memcache' to see if that would help find it, but
didn't work.
I read some things online about how a 'Di' thing can conflict with this. I verified my config does not load anything with 'Di'
Verified that the abstract factory setting is loaded in the config under Service Manager
Code:
config var_dump showing the abstract factory part is loading
$sm = $this->getServiceLocator();
$config = $sm->get('config');
var_dump($config);die();
'service_manager' =>
array (size=3)
'abstract_factories' =>
array (size=2)
0 => string 'Zend\Cache\Service\StorageCacheAbstractServiceFactory' (length=53)
1 => string 'Zend\Log\LoggerAbstractServiceFactory' (length=37)
'aliases' =>
array (size=2)
'translator' => string 'MvcTranslator' (length=13)
'db' => string 'Zend\Db\Adapter\Adapter' (length=23)
'factories' =>
array (size=1)
'Zend\Db\Adapter\Adapter' => string 'Zend\Db\Adapter\AdapterServiceFactory' (length=37)
My cache.local.php and it's in the autoload directory of zendframework 2 (taken from above tutorial link and removed the 'd')
I think this is what I need to change just not sure how....
return array(
'caches' => array(
'memcache' => array( //can be called directly via SM in the name of 'memcache'
'adapter' => array(
'name' =>'memcache',
'lifetime' => 86400, //24 hours
'options' => array(
'servers' => array(
array(
'127.0.0.1',11211 //Server IP, Port
)
),
'namespace' => 'MYMEMCACHENAMESPACE',
'liboptions' => array (
'COMPRESSION' => true,
'binary_protocol' => true,
'no_block' => true,
'connect_timeout' => 120
)
)
),
'plugins' => array(
'exception_handler' => array(
'throw_exceptions' => false
),
),
),
),
);
You need to install the PHP library memcached so you can use ZFs Memcached Adaptor. ZF does not have an adaptor for the memcache library so it's trying to use the library directly which does not have a setter for liboptions. Either install memcached or remove liboptions in your config and you should be all set.

ZF2+Doctrine2 - Suddenly getting error on Mac: "Doctrine\ORM\EntityManager"; no instance returned

I am working on building a Zend Framework 2 (ZF2) website using Doctrine2 DBAL/ORM, where I develop equally on Windows and Mac, sometimes Linux (Ubuntu) (I like the all-around experience).
In composer.json I have the following versions:
"doctrine/doctrine-orm-module": "^0.9.1"
"zendframework/zendframework": ">=2.3.2,<3.0.0"
At first, my website ran fine on all three environments using XAMPP (Apache 2.4.16, MySQL 5.0.11, and PHP 5.6.12). But suddenly, after I performed some changes on Windows and pulled those changes from GitHub to my Mac computer, Doctrine started failing with the following exception message:
An exception was raised while creating "Doctrine\ORM\EntityManager"; no instance returned
I got this exception a lot while configuring Doctrine2 in ZF2. But once I was done, things just worked. That is until it broke on Mac, only! It still works fine on Windows.
I have cleared the cache completely (rm data/cache/*) and I have verified the integrity of my configuration files. The only difference in configuration between Windows and Mac is that I provide a unix_socketpath for MySQL (see below).
My config/application.php:
<?php
return array(
'modules' => array(
// ...
'DoctrineModule',
'DoctrineORMModule',
),
'module_listener_options' => array(
// ...
),
);
My config/autoload/databases.local.php looks like this (with changed values for database server login information):
<?php
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'unix_socket' => '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock', // This is for Mac
'host' => 'some_host',
'port' => '3306',
'user' => 'some_user',
'password' => 'some_password',
'dbname' => 'some_database',
)
)
),
'configuration' => array(
'orm_default' => array(
'proxy_dir' => 'core/server/data/DoctrineORMModule/Proxy',
'proxy_namespace' => 'DoctrineORMModule\Proxy',
)
)
),
);
As mentioned, these configurations work on Windows (I can retrieve and use the EntityManager) and is a 1:1 mirror onto my Mac solution. So what happens?
When I check the cached configuration file, data/cache/module-config-cache.application.config.cache.php, on my Mac, the database login informations are incorrect, having the following values:
// ...
array (
'host' => 'localhost',
'port' => '3306',
'user' => 'username',
'password' => 'password',
'dbname' => 'database',
),
// ...
Obviously these are wrong. But how can ZF2 suddenly generate incorrect configurations on Mac?
I even tried checkout out previous commits from Git on my Mac, which I know worked for certain. But the same problem occurs. The only difference, I suspect might have influence on this behavior, is that I ran composer.phar update, which might've changed the versions of ZF2 and/or Doctrine2.
The problem boiled down to the glob pattern for the autoload config files being incorrect.
$appConfig['module_listener_options']['config_glob_paths'][$index] = getcwd() . '/' . $path;
getcwd() had an incorrect pointer, despite having specified the following:
define('ROOT_PATH', realpath(__DIR__ . '/../../../..'));
chdir(ROOT_PATH);
For some reason I cannot fathom, it worked before on Windows and Ubuntu, but not on Mac. Now it works in all three environments.
It's an almost invisible error and required line-by-line debugging through the bootstrapping logic.
In my case, this error message were thrown, when the database was missing!

using yii with memcache, error when one of two server fails

i have a problem with yii and storing data in memcache. For my application i use system.caching.CMemCache and the following config:
'servers' => array(
'server1' => array('host' => 'localhost', 'port' => 11211, 'weight' => 50),
'server2' => array('host' => '192.168.0.2', 'port' => 11211, 'weight' => 50)
),
if memcache on both systems is running, everything is ok and the values get spread up on the servers. but if one server fails (or if i stop the memcache manually) the application throw errors like
MemcachePool::get(): Server 192.168.0.2 (tcp 11211, udp 0) failed with: Connection refused (111)
this isn't really nice, i thought if one server failed yii would choose another server for reading and writing or at least produce some cache misses and do not throw an exeption :(
is this normal or are there some configuration issues?
I think its normal you are seeing those messages as discussed here, given you are using memcache extension
And also read this SO.
There are two version of extension for php one is memcache while the other is memcached. You can install each of them on ubuntu box like :
sudo apt-get install php5-memcache
and
sudo apt-get install php5-memcached
Memecached extension handles failover situations ,as I read from the above links and confirm by testing following settings in yii
'cache'=>array(
'class'=>'CMemCache',
'useMemcached'=>true,
'servers'=>array(
array(
'host'=>'localhost',
'port'=>11211,
'weight'=>60,
),
array(
'host'=>'192.168.33.31',
'port'=>11211,
'weight'=>30,
),
),
),
Install the memcached extension for php as described above and add 'useMemcached'=>true, setting to cache configs.As I test on my localhost, it handles the failover situation, but the page response time drops significantly.
Hope this will be helpful.
Is this variable true?
http://www.php.net/manual/en/memcache.ini.php#ini.memcache.allow-failover
Otherwise this link can also be useful:
Memcache : Confusions
(Probably this is only a notice.)

zend memcache gives error

Please help me for the issue of getting a error, while trying to implement a memcache with my application to speed up as below:
"The memcache extension must be loaded for using this backend"
I am using the zend version: 1.11.11.
I have the php_memcache.dll in my c:/wamp/bin/php/php5.4.3/ext/
Please help me to solve this issue.
Thanks in advance.
I have implemented with below script:
$frontendOptions = array(
'lifetime' => 7200, // cache lifetime of 2 hours
'automatic_serialization' => true
);
$backendOptions = array(
'servers' =>array(
array(
'host' => 'localhost',
'port' => 11211
)
),
'compression' => false
);
// getting a Zend_Cache_Core object
$cache = Zend_Cache::factory('Core',
'Memcached',
$frontendOptions,
$backendOptions);
Zend_Registry::set('mem_cached', $cache);
you should check with carefully some point as below
mainly PHP has two Memcached libraries with confusing names :
Memcache
Memcached (notice the d)
Your code needs the first one. Just do a simple pecl uninstall memcached and then pecl install memcache, modify your php.ini to include the appropiate .so and it should work for you.

Categories