We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Questions should go to https://forum.phalconphp.com YES Documentation issues should go to https://github.com/phalcon/docs/issues
Just try to deploy my app example to Heroku, and using heroku addon memcachedcloud the memcached service to store my session data.
from the DOC of memcachedcloud service. we know to have using setSaslAuthData method to setup the user_name & user_password
such like :
$mc = new Memcached(); $mc->setOption(Memcached::OPT_BINARY_PROTOCOL, true); $mc->addServers(array_map(function($server) { return explode(':', $server, 2); }, explode(',', $_ENV['MEMCACHEDCLOUD_SERVERS']))); $mc->setSaslAuthData($_ENV['MEMCACHEDCLOUD_USERNAME'], $_ENV['MEMCACHEDCLOUD_PASSWORD']);
but during looking on the source code of /phalcon/cache/backend/libmemcached.zep#L115 in the _connect method, the memcached object was not try to setup with setSaslAuthData .
In current phalcon version 3.4.0 & 3.3.2 , i can not using heroku memcachedcloud addon. without setSaslAuthData method.
here is my temporary solution :
/* step 1 : extent current Phalcon\Cache\Backend\Libmemcached class and override the _connect method */ class MyLibmemcached extends Phalcon\Cache\Backend\Libmemcached{ function __construct($frontend, $options){ parent::__construct($frontend, $options); } /** * Create internal connection to memcached */ public function _connect() { $options = $this->_options; /* .... */ $memcache = new \Memcached($persistentId); /* .... */ // ADD the setSaslAuthData if(!empty($options['saslAuthData']['username']) && !empty($options['saslAuthData']['password'])) { $memcache->setSaslAuthData($options['saslAuthData']['username'], $options['saslAuthData']['password']); } $this->_memcache = $memcache; } } /* step 2 : extent current Phalcon\Session\Adapter\Libmemcached class and override the __construct method */ use Phalcon\Cache\Frontend\Data as FrontendData; class MySession extends Phalcon\Session\Adapter\Libmemcached{ function __construct($options){ parent::__construct($options); /* .... */ $saslAuthData = (!isset($options['saslAuthData']) ? [ 'username' => null, 'password' => null, ] : $options['saslAuthData']); if (!isset($options['saslAuthData'])) { throw new Exception('No servers given in options'); } $this->_libmemcached = new MyLibmemcached( new FrontendData(['lifetime' => $this->_lifetime]), [ 'servers' => $servers, 'client' => $client, 'prefix' => $prefix, 'statsKey' => $statsKey, 'persistent_id' => $persistentId, 'saslAuthData' => $saslAuthData, ] ); } } /* step 3 : at service session bootstrap, just passing the username / password from Heroku $_ENV */ if(isset($_ENV['MEMCACHEDCLOUD_SERVERS'])) { $mc_servers = array_map(function($server) { return explode(':', $server, 2); }, explode(',', $_ENV['MEMCACHEDCLOUD_SERVERS'])); } else { $mc_servers =[[ "host" => "127.0.0.1", "port" => 11211, "weight" => 1, ]]; } $session = new MySession( [ "servers" => $mc_servers, "client" => [ \Memcached::OPT_HASH => \Memcached::HASH_MD5, \Memcached::OPT_PREFIX_KEY => "prefix.", \Memcached::OPT_BINARY_PROTOCOL => true, ], "lifetime" => 3600, "prefix" => "my_", "saslAuthData" => [ 'username' => (isset($_ENV['MEMCACHEDCLOUD_USERNAME']) ? $_ENV['MEMCACHEDCLOUD_USERNAME'] : null), 'password' => (isset($_ENV['MEMCACHEDCLOUD_PASSWORD']) ? $_ENV['MEMCACHEDCLOUD_PASSWORD'] : null) ], ] );
now, i can using the heroku memcachedcloud addon as my session service.
The text was updated successfully, but these errors were encountered:
Closing in favor of #13855. Will revisit if the community votes for it, or in later versions.
Sorry, something went wrong.
Resolved in #14120
niden
No branches or pull requests
Just try to deploy my app example to Heroku, and using heroku addon memcachedcloud the memcached service to store my session data.
from the DOC of memcachedcloud service. we know to have using setSaslAuthData method to setup the user_name & user_password
such like :
but during looking on the source code of /phalcon/cache/backend/libmemcached.zep#L115
in the _connect method, the memcached object was not try to setup with setSaslAuthData .
In current phalcon version 3.4.0 & 3.3.2 , i can not using heroku memcachedcloud addon. without setSaslAuthData method.
here is my temporary solution :
now, i can using the heroku memcachedcloud addon as my session service.
Details
The text was updated successfully, but these errors were encountered: