Hello,
Does anyone use amazon elasticache redis as a session adapter for phalcon app? i've been straggling for may session manager because my app is setup in amazon load balancer.
Thanks
|
May '18 |
4 |
435 |
0 |
Redis is supported in Phalcon, but Amazon elasticcache might be different thus you'd need to write your own wrapper.
In aws I use DynamoDB to share sessions between instance behind load balancer.
https://docs.aws.amazon.com/aws-sdk-php/v2/guide/feature-dynamodb-session-handler.html
In aws I use DynamoDB to share sessions between instance behind load balancer.
https://docs.aws.amazon.com/aws-sdk-php/v2/guide/feature-dynamodb-session-handler.html
I use the elasticache endpoint as a Adapter host and it seems working fine. but, will look into this will choose which one will save me money.
https://docs.aws.amazon.com/aws-sdk-php/v2/guide/service-elasticache.html
i've seen this but if i use this it means that i have to wrewrite my app on how they access the session and my app is lit bit large so i have to invest quite time that i'd rather use a JWT than doin this.
Thanks anyway.
In aws I use DynamoDB to share sessions between instance behind load balancer.
https://docs.aws.amazon.com/aws-sdk-php/v2/guide/feature-dynamodb-session-handler.html
how did you initialize the dynamodb connection in phalcon? does it in service or in public index?
or something like this
$di->setShared('session', function() {
$dynamoDb = DynamoDbClient::factory(array(
'region' => '<region name>',
));
$sessionHandler = SessionHandler::factory(array(
'dynamodb_client' => $dynamoDb,
'table_name' => 'sessions',
));
$sessionHandler->register();
});
as replacement of
$di->setShared('session', function() {
$session = new SessionAdapter(array('uniqueId' => '****'));
$session->start();
return $session;
});
Not as replacement, you need to initialize your aws session handler and after do your session process as usual.
$di->setShared('session', function() {
$dynamoDb = DynamoDbClient::factory(array(
'region' => '<region name>',
));
$sessionHandler = SessionHandler::factory(array(
'dynamodb_client' => $dynamoDb,
'table_name' => 'sessions',
));
$sessionHandler->register();
$session = new SessionAdapter(array('uniqueId' => '****'));
$session->start();
return $session;
});
Not as replacement, you need to initialize your aws session handler and after do your session process as usual.
$di->setShared('session', function() { $dynamoDb = DynamoDbClient::factory(array( 'region' => '<region name>', )); $sessionHandler = SessionHandler::factory(array( 'dynamodb_client' => $dynamoDb, 'table_name' => 'sessions', )); $sessionHandler->register(); $session = new SessionAdapter(array('uniqueId' => '****')); $session->start(); return $session; });
Thanks for this, i made it work and will just see which one saves me a lil bit of money over elasticache or dynamodb