Welcome Guest, Not a member yet? Register   Sign In
CI 3 using native sessions instead of driver
#5

(This post was last modified: 12-12-2019, 09:03 AM by blasto333.)

(12-12-2019, 09:00 AM)dave friend Wrote:
(12-12-2019, 08:35 AM)blasto333 Wrote: phpredis extension has much finer grain control with locking; so it should perform just as good as mysql GET_LOCK without database load. You can do the following. (microseconds instead of 1 second).

; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live (in seconds)? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds (µs)?. Defaults to: 2000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry (-1 means infinite). Defaults to: 10
redis.session.lock_retries = 10

My main question though is if I implemented native sessions correctly? Also I cannot use file based sessions as the application is behind a load balancer on multiple web servers.

Do you understand that CI 3 uses "native" sessions?  Do you realize the main purpose of the CI_Session library is to provide database drivers? PHP does not have any built-in ability to use databases. To do that it is necessary to write a custom session handler, i.e. the CI_Session class and its associated drivers.

You cannot solve the locking issue by removing the locks. (Well, you can, but it would be bad practice.) It's not clear to me that's what you have in mind, but if it is read this. If you have read that before then read it again more carefully.

I know it uses native session and has custom handlers; but I still want to be able to use methods such as set_userdata which is why I create MY_Session.php and removed the linking of session handling to drivers. Then I can enable phpredis session extension in php.ini

I don't want to remove the lock just make it not lock as long as php CI redis driver does (1 second for 30 tries). I am asking if what I did in MY_Session.php seems sufficient.
Reply


Messages In This Thread
RE: CI 3 using native sessions instead of driver - by blasto333 - 12-12-2019, 09:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB