On Fri, Oct 29, 2010 at 9:18 PM, Jonas H. <jo...@lophus.org> wrote:
> Hi folks,
>
> upon the recommendation on the django-nonrel mailing list, I'll re-post my
> original question here:
>
> -- Begin original message --
> I just tried to use MongoDB as cache backend (only for development ;-) but
> it failed because apparently the Django guys do hand-written SQL in the
> database cache backend, probably for the sake of performance.
>
> Of course I could write a MongoDB cache backend myself -- which probably
> wouldn't be /that/ hard -- but isn't database abstraction the job for
> Django's database framework? [...]
> -- End original message --
>
> How do think about that? I'm sure a very thin abstraction layer would
> suffice. Or, if possible (I'm not /that/ deep into the Django ORM, so I
> can't tell), some small part of the ORM's query abstraction could be used so
> the database backend would not require a certain type of database?

You're correct -- we *could* use Django's ORM for the cache backend.
However, we haven't -- and for good reason.

Caching is, by very definition, something that needs to be speed
optimized. The queries required by a cache backend are very simple,
and need to run as fast as humanly possible -- otherwise you're
missing the purpose of having a cache.

If we were to use the ORM for the cache backend, the gain in
readability would be minor, and while the overhead of using the ORM is
small, it is non-zero, and when you're talking about caching, every
little bit counts.

Writing a MongoDB (or any other non-SQL) cache backend shouldn't be a
particularly onerous task; after all, the queries are simple, and the
.The SQL backend is only 150 lines of code; a backend for any noSQL
backend should run to about the same line count.

An abstraction layer might be possible, but if you look at the source
code for the DB backend, there isn't much there that isn't raw SQL
anyway -- the cache backend essentially *is* the abstraction layer.

Yours,
Russ Magee %-)

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

Reply via email to