Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

AuthDBI : Cache problem + potential error in source ?

by Sihal (Pilgrim)
on Jan 27, 2003 at 14:45 UTC ( [id://230233]=perlquestion: print w/replies, xml ) Need Help??

Sihal has asked for the wisdom of the Perl Monks concerning the following question:

My problem is 2 fold.
First, I have a strong problem with authDBI and his cache:
If I change a user's information in my database , the cache is not rinsed.
"Well actually, it's normal" I thought. "let's wait for the cleanup delay of the cache, and it'll be ok."

I wait, and no change. What the heck: the cache is not cleaned?
After a lot of searching, we finally understood that the cache was cleaned if you waited the full cache cleanup delay AND if somebody elses logs in. Is this normal ?
For me it's a real pain and I'd really like the cache to be cleaned every 5 minutes, whatever the actions of the users.

Now for the second part of my question:
I went into AuthDBI source code, and this part seems strange to me :
sub setCleanupTime { my $class = shift; my $cleanup_time = shift; # sanity check $CleanupTime = $cleanup_time if ($cleanup_time =~ /\-*\d+/); }
Oh geez, nevermind I realize that my question is stupid while asking it :-(.
Does anybody has some feedback on my first point?

Replies are listed 'Best First'.
Re: AuthDBI : Cache problem + potential error in source ?
by perrin (Chancellor) on Jan 27, 2003 at 15:51 UTC
    It uses a mod_perl cleanup handler to do the cache cleanup, and those only run when the server handles a request. If no one is using the server, the cache will not get cleared.

    It's not actually waiting for someone else to log in, but rather for anyone to do ANYTHING on the server. On a server with some traffic, you would not notice a delay.

    If you frequently have only one person on the server and are concerned about this, you could run a cron job to request a page from the server and trigger the cleanup handler every minute or so.

      Thanks this is interesting.
      I suppose all our fustration came from the fact that we expected the cache to clean itself up upon apache restart or expiration of the cache delay... And since we cannot prevent our users to login all the time, even if we ask them to keep quiet for 2 minutes ( I hate those marketing guys :-) ).
      Thanx for pointing out that a simple cron would actually solve the problem. Sometimes simples things work best.
        The reason it doesn't clean up when you restart is the shared memory that it uses for storing the cache. You could have a separate cache per process instead. (There's a parameter to control this.) You could also change the module to use something better like Cache::Mmap instead.

        If no one logs in for a while and the data expires, the first time someone performs an action on the server it will still have stale data, but at the end of that request it will be cleared. So, you could say something like "if you've changed your password and your new login doesn't work, just try it again and it will."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://230233]
Approved by diotalevi
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2025-02-08 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (95 votes). Check out past polls.