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 complicated there.

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" <[EMAIL PROTECTED]> wrote:

Dustin,

Do you normally use memcached in Rails or primarily in Java (I figured
Java since you wrote spymemcached) :-)

Ryan


On Fri, Jun 20, 2008 at 3:00 PM, Dustin Sallings <[EMAIL PROTECTED]> wrote:

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 memcached
requests AND database requests?

We get that in rails. You just say something like ``SomeType.get_cache 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 incrementally
more complicated code.

--
Dustin Sallings



Reply via email to