We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Session using Redis: php.ini vs Phalcon\Cache\Redis

Hi all,

I want to use redis to share and store my php sessions. I've tested Phalcon Redis implementation and it works fine. Now, I'm not sure what the benefits really are: I can setup Redis as my session handler at the php level (php.ini) it would be easier and transparent for my app.

So it's an open question, but why should I use Phalcon to manage my Redis connection ?

Performance? don't see how phalcon could be more efficient (has anyone benchmarked it ? ) Error management? not really reliability/stability ? don't think so

I could see a few small benefits, but that's not much:

  • if I want to store other types of data (non-session, static data) using redis too
  • a few more options for prefix and expiration...

I might be missing something. Please enlighten me if so :)



34.6k
Accepted
answer

There are no performance improvements in using Phalcon's managament for session. However Phalcon\Session makes use of adapters, and the idea is that you can use one adapter or another depending on configuration settings in your application which increases the flexibility of your architecture.

Ok, that totally make sense.

I don't really need that level of flexibility since I'm sharing the infrastructure with another app. Both are depending on Redis, so it's not going to go anywhere anytime soon. But since I plan to use app-cache, I may just use Phalcon Adapter anyway :)

Thank you for your answer.