Few queries on atomicity of requests
dustin at spy.net
Sat Jun 21 00:37:21 UTC 2008
I use memcached for rails, java, and django. I'm not too picky.
In any case, the usage is further away from the database than this
thread seems to be advocating.
In rails, I'm mostly caching objects where each is constructed from
a row in a db. This sometimes includes collections of objects. I
also sometimes cache view layer stuff, but invalidation can get more
In Django, it's mostly views. Invalidation is still a pain, but
not so much in my Django apps that a short cache time doesn't make it
worth my while.
In one of my java apps, I'm caching foreign objects -- that is,
objects that live completely outside of my application and whose
lifecycles are completely outside of my control. Even then, with a
bit of creativity, I can cache collections of objects with no
expiration and nobody has to know.
Dustin Sallings (mobile)
On Jun 20, 2008, at 12:08, "Ryan LeCompte" <lecompte at gmail.com> wrote:
> Do you normally use memcached in Rails or primarily in Java (I figured
> Java since you wrote spymemcached) :-)
> On Fri, Jun 20, 2008 at 3:00 PM, Dustin Sallings <dustin at spy.net>
>> On Jun 20, 2008, at 11:42, Daniel wrote:
>> Wouldn't it be nice to get the speed boost of caching in all parts of
>> your application without needing to complicate your code with
>> requests AND database requests?
>> We get that in rails. You just say something like
>> 81754'' to get a SomeType from the cache. If it's not in the
>> cache, it'll
>> get it from the DB and put it in the cache and then return the value.
>> Similarly, if you add this to your model:
>> after_save :reset_cache
>> It will automatically freshen the cache after you save a record.
>> If it complicates the API, you're probably doing it wrong.
>> Of course, you can do more complicated stuff, but it's only
>> more complicated code.
>> Dustin Sallings
More information about the memcached