tracking online user count under memcached

Skylos skylos at gmail.com
Fri Jun 17 21:35:33 PDT 2005


You certainly could cache for an acceptably granular period of time
the current logins.

if fail to fetch login_count
  query database
  store login_count in cache with expiration
end if
output login_count

thus cutting down the silly queries for login counts to an acceptable
interval.  Fast results for your count, granularity as small as you
like (run the query every 5 seconds, the db won't care).  Performance
from memcached, reliability from the db.

Skylos



On 6/17/05, Xuefer <xuefer at gmail.com> wrote:
> > So say your code gets cookie 332233, if memcached doesn't have data,
> > it yanks from DB..  Otherwise, it yanks data from memcached for
> > relevant needs.  at some point during the request it checks exist of
> > sky-STORED - if it doesn't exist, it dumps any changes/updates as
> > relevant into the database, and recreates sky-STORED with another 60
> > second expiration.
> >
> > You cut DB hits mostly, and you still have minute-resolution on
> > session activity.  Performance from memcached, reliability from db.
> >
> > Skylos
> >
> great, that's what i need.
> (i was hoping there is a way to do something like
> session_onstart/onend, as doing a "select count(*) from table where
> location=..." is a bit slow)
> i'll look into it
>


More information about the memcached mailing list