On 29/07/2010 17:16, Jirka Vejrazka wrote:
>   Well, it probably depends on the frequency od data change as well as
> other factors. I personally don't like spawning another thread in a
> request-response cycle, but if it works for you, be happy with it :)
> 
>   Based on the print statement on your code I assume your website does
> run under the development server, so you may have very different
> requirements than a usual production (read: always running) site :)
> 
>> As for the cache key, i did the reverse because i thought i had
>> read in the documentation that this was the standard way Django puts
>> stuff in the cache.
> 
>   Sure - you can do it, no problem. The reason Django uses it is that
> it caches various pages and the url pattern is a good way to make sure
> that the cache key is unique for each page. You could put anything
> there, even a static string :)
> 
>> But it's not the link as returned by reverse, though i haven't found yet
>> what it is. If i find it, i can set i correctly in the thread so that I don't
>> have to manually check to see if the page is cached when a statistics page
>> is called.
> 
>   You will always have to check it, as it's not guarranteed to stay in
> the cache forever. Assuming that the data is in cache is a Bad Thing
> :)
> 
>   If you set your cache key to "yearly_statistics" or something
> similar, you will have no issue with figuring out what the key is :)
> 
>   Cheers
> 
>     Jirka
> 

I'm indeed running the development server for the moment but i'll
switch to a Apache/wsgi/nginx setup (i've already tested it).

I've just installed memcached and now i can see what links Django uses
ask keys. As for your comment, that i always have to check, you're right
but i rely on the Django caching mechanism to do that by specifying
cache_page in my urls.py (first i used the cache_page decorator):
...
url(r'^statistics/top/user/yearly/$', 
cache_page(stats_top_callers_per_year,60*60*24), 
name='stats_top_callers_per_year'),
...

I want to put the data in the cache with a key that Django generates itself
to fetch the data from the cache.

That's why i asked on what Django uses as a key to set and entry in the cache.
If i generate the page and put it on the cache and then rely on Django to get 
it,
the key i use needs to be the same as Django uses otherwise the page isn't 
found in the
cache and the page is generated again and then cached by Django.
And that's just what i want to avoid.
I'm happy to leave the caching to Django, i just want to "help" cache it 
initially :)

Anyway, thank you, you have given me lot's of info & insights !

Regards,
Benedict

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

Reply via email to