04-10-05 01:45 AM
Any drawbacks if we just look at the mtime of the file? If it's older
than cur_time - expiration_time then delete it. That way we wouldn't
need to open it and check if it has expired. It would be uglier but it
would be faster, and the whole purpose of creatnig FileSession was to
maximize performance (at least that was my original purpose).
Jim Gallacher wrote:
> Barry Pearce wrote:
>
>
>
> Yes, but the proposed code for FileSession could be a problem if there
> are a large number of sessions. The cleanup is run once in some random
> number of requests approximating 1000.
>
> Psuedo code:
>
> for sess_file in session_file_list:
> sess_data = cPickle.load(sess_file)
> if session_has_expired(sess_data):
> delete_file(sess_file)
>
> Every session file is unpickled to see if the session has expired. This
> has GOT to hurt performance when the number of sessions rises to a
> significant number.
>
> Regards,
> Jim
>
>
>
[ Post a follow-up to this message ]
|