http://docs.djangoproject.com/en/dev/topics/http/sessions/#using-cached-sessions

You'd want to use the write-through suggested by first configuring something
like memcached, and then follow:

"For persistent, cached data, set
SESSION_ENGINE<http://docs.djangoproject.com/en/dev/ref/settings/#std:setting-SESSION_ENGINE>to
"django.contrib.sessions.backends.cached_db". This uses a write-through
cache – every write to the cache will also be written to the database.
Session reads only use the database if the data is not already in the
cache."



On Thu, Nov 18, 2010 at 12:57 AM, Jani Tiainen <rede...@gmail.com> wrote:

> Approach 2 seems to be something what I used in magical J2EE world and
> where
> this kind of a caching was natural.
>
> Any hints or links how to proceed or do I need to reinvent the wheel by
> myself?
>
> --
>
> Jani Tiainen
>
> On Thursday 18 November 2010 00:56:43 Joe Kondel wrote:
> > I would second Russ' memcached recommendation.
> >
> > We use custom authorization modules that do some obj level lookups in
> > addition to some other ACL type stuff. We've cut down seriously on the
> > amount of DB hits by:
> >
> > 1- Caching a lot of the more static type of authorization rulesets ( the
> > ACLs )
> > 2- Using cache-then-db backed sessions to store certain types of
> credential
> > information.
> >
> > Depending on your needs it could be as quick of a win as Russ' flag(s)
> > method or you might ( as I have ) run into some migraine inducing cache
> > invalidation strategies.
> >
> > Good luck either way!
> >
> > -j
> >
> > On Wed, Nov 17, 2010 at 9:59 AM, Russ B. <russell.bernha...@gmail.com
> >wrote:
> > > Authorize them against the DB the first time, then attach some flag to
> > > their session that represents "authorized" that your views check on
> > > instead of having them work with the auth models (or however you're
> > > doing it). If the "authorized" flag doesn't exist, redirect them to
> > > the login page.
> > >
> > > You may also be interested in reading about memcached and how to
> > > configure Django to work with it; it's cut back a lot of my own
> > > database hits.
> > >
> > > Russ B.
> > >
> > > On Nov 16, 10:34 pm, Jani Tiainen <rede...@gmail.com> wrote:
> > > > Hi,
> > > >
> > > > I've application that uses ajax and most of my views are protected by
> > > > @login_required decorator, some of them with additional permissions.
> > > >
> > > > Problem is now that I get lot of hits to database to check rather
> > > > static credential information.
> > > >
> > > > Is there way to cache these credentials so that I would hit database
> > > > more infrequently?
> > > >
> > > > --
> > > >
> > > > Jani Tiainen
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> <django-users%2bunsubscr...@goog
> > > legroups.com> .
> > > For more options, visit this group at
> > > http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to