phalcon
phalcon copied to clipboard
Support Redis Cluster
Hi As you know as of Redis 3 , this system support clustering and sharding in a way that a system can have redundant session and cache backend .
I checked Zephir codes of Redis backend cache and noticed Phalcon calls it using
new Redis();
new version of phpredis (Redis php driver) now supports clustering and array (not sure when they've added Redis array support but Redis cluster support is somehow new )
but they can't be called using normal new Redis() method and need to be called like these :
$obj_cluster = new RedisCluster(NULL, Array('host:7000', 'host:7001', 'host:7003'));
$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"));
This way we will have HA redis cluster for backend cache and session (BTW the driver now supports session clustering and it can be done using php.ini , not tested by myself but i'll test it soon)
So it would be great if we can take advantage of Redis Cluster and Redist array natively in Phalcon .
:+1:
Any progress?
+1
+1
+1
It this feature already in some roadmap?
I guess not.
I don't want to sound rude, but technically, it's a blocker and still unresolved. If you want to use Phalcon with Redis for bigger project, you must to use Redis Cluster (because failover, HA, etc.).
You can always do PR, feel free to do it.
This is definitely not a long term solution, but if you have PHPRedis configured to handle sessions with RedisCluster then you can cheat a little by leveraging the abstract class Phalcon\Session\Adapter since it uses the superglobal $_SESSION. I was able to create a class that extends it and let PHPRedis automatically handle session handling. For example, I created:
<?php
class RedisClusterSession extends Phalcon\Session\Adapter
{
}
Then in index.php:
// Setup the session component
$di->setShared('session', function () {
$session = new RedisClusterSession();
$session->start();
return $session;
});
Closing in favor of phalcon/cphalcon#13855. Will revisit if the community votes for it, or in later versions.
I'm considering contributing to this issue. Got off track by missing RedisCluster adapter about... 7 years ago? It's crazy its not yet implemented. Is there a reason you are not implementing this? We don't have volounteers or there is a hidden issue in here?
@yergo Lack of knowledge and volunteers. To get this going I will need to study on how the cluster works and then write the implementation.
If you are interested in making an adapter for this, you can try it in the https://phalcon/phalcon repository first with a PHP implementation. Then it would be easy to port it to cphalcon. The Storage classes work just fine for phalcon/phalcon