> cache.set(reverse("stats_top_callers_per_year"), ret_val)
Hi,
it's your code and I won't try talk you out of it :)
However, I don't see any reason why you couldn't call
"stats_top_caller_per_year" from an external script, unless you do
some magic related to request in that function. You're overriding the
user to be the one with pk=1 anyway, so you can do the same in a
script launched by cron the same way.
As long as you have a system-wide cache (ideally memcached backend),
nothing prevents you from doing that.
As for the cache key, it can be anything you want as long as it's
unique, less than the backend allows (I think it's 250 chars for
memcached, see the docs) and does not contain whitespaces (some cache
backends do allow those). A common idiom is an md5 of something that
uniquely identifies the cache object, but in your case you'd be free
to call it "stats_top_callers_per_year" or similar. No need to play
with reverse().
It's all just Python and Django does not really get much in a way
unless needed. So, no one tells you what the cache keys must look
like, and it's unlikely that you'd stumble upon cache keys Django uses
internally.
HTH
Jirka
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment