skip to Main Content

I was reading the source code for Redis session driver. In the gc function it return true and says Redis handles this.

How does redis decide when to evict data with a sess_expiration = 0? I don’t want redis to fill up when these sessions can be deleted.

2

Answers


  1. Basically said, you don’t.

    We had the same problem – a possible approach would be to define a max expiration time (e.g. 3, 6, 12 months).

    Additionally you can track the time where the session was accessed last, and delete all inactive sessions after a defined period.

    For this you have to write your own GC. (We installed a cron job which runs every 24 hours).

    Login or Signup to reply.
  2. I’m not very familiar with the topic, but I think:
    redis follows a specific strategy to manage your session by default. Accordingly: GC saves a default expire time after the session information for use in the next entry. In doing so, it looks at its configuration (Did you create a table to store Session? When should you save it?).

    It made it possible to customize this part. So you can manage your session by writing your own handlers. If you want, you can store the session information in any place without taking it to the database side (like cookie). Also you can set up your own web service and manage the remember me information from there, is another option.

    My understanding is that if you set sess_expiration to 0 than it will manage itself. Otherwise you can set a short time like 40 minutes and you can use like sintakonte’s corn job. (I think no way to write your own GC, You can customize your session handler like that PK_Session)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search