Re: Dynamic settings variables (dynamic global variable)

2012-02-09 Thread bfrederi
Makes sense. I actually ended up using your example and it worked well as far as I can tell. And you actually explained the importing too, which is where I messed up previously. Also, I made the mistake of putting it in a file that was already importing a bunch of other things, so I got wrapped up

Re: Dynamic settings variables (dynamic global variable)

2012-02-09 Thread Doug Ballance
> Doug, I don't see how the LazyFetch you wrote is much different than > what akaariai shared? Can you explain to me what the difference is? > And I'm not saying that in a condescending way, I'm saying I'm just > not sharp enough on my Python to recognize the difference. Slightly different impleme

Re: Dynamic settings variables (dynamic global variable)

2012-02-09 Thread bfrederi
I tried akaariai's method, but I may have done the importing wrong. It seemed to make apache struggle mightily to the point where it was unusable for some reason. Doug, I don't see how the LazyFetch you wrote is much different than what akaariai shared? Can you explain to me what the difference is

Re: Dynamic settings variables (dynamic global variable)

2012-02-09 Thread bfrederi
Thanks Andy, I didn't know you could use a cache by name. That will be helpful. On Feb 8, 9:22 pm, Andy McKay wrote: > You can define multiple caches: > > https://docs.djangoproject.com/en/1.3/topics/cache/#django-s-cache-fr... > > You could then use a file system cache or your own local memcache

Re: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread Doug Ballance
I made an error when I changed a variable name just before posting. Replace "self._age" with "self._last_updated". -- 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

Re: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread Doug Ballance
A method similar to what Anssi describes is what we use for local caching of data that is too large to comfortably fetch from cache/ parse from file every time we need it. A Doing a lazy fetch with a maximum age like that also helps with load times since it is only fetched when accessed. Of course

Re: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread Andy McKay
You can define multiple caches: https://docs.djangoproject.com/en/1.3/topics/cache/#django-s-cache-framework You could then use a file system cache or your own local memcache. https://docs.djangoproject.com/en/1.3/topics/cache/#filesystem-caching You can then get that cache and access it in you

Re: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread bfrederi
I'm already using memcached over http so I can have multiple memcached instances. But there isn't any way to set priority or which cache the item goes to or is pulled from. So if I had a local memcached instance, there's no way I could be sure which memcached instance the data was coming from. I al

Re: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread Brett Epps
I'd recommend caching the data using Django's caching framework and either the local memory or memcached backend. To update the cache, write a management command that runs periodically as a cron job. (If you find yourself needing more sophisticated background task management, check out Celery.)

Re: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread bfrederi
So would I put that class in my settings.py? Where would I put that class to make sure that the data is frequently retrieved from local memory? On Feb 8, 4:47 pm, akaariai wrote: > On Feb 9, 12:14 am, bfrederi wrote: > > > I have some data that I retrieve using urllib and then cache on a > > dif

Re: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread akaariai
On Feb 9, 12:14 am, bfrederi wrote: > I have some data that I retrieve using urllib and then cache on a > different server that I frequently use through my site. Since it gets > used so frequently, I was wondering why it might be a good/bad idea to > make the urllib request in the settings.py. It'

Dynamic settings variables (dynamic global variable)

2012-02-08 Thread bfrederi
I have some data that I retrieve using urllib and then cache on a different server that I frequently use through my site. Since it gets used so frequently, I was wondering why it might be a good/bad idea to make the urllib request in the settings.py. It's data that gets changed infrequently, but sh