OverClocked
OverClocked

Reputation: 1197

Django memcached won't cache a large template output

I am using Django with memcached.

In one of my templates, I added

{% cache 28800 template_browse_gene_list %}
...
{% endcache %}

The stuff in the block is rather large, just over 1 MB; it is the result of iterating through an expensive SQL that returns lots of data. Since QuerySet is lazily evaluated, using the cache here avoids the SQL, if cache works.

When I use locmem as the cache backend, this works. I avoid the SQL and get cached result.

When I hookup memcached, with -I 4m setting, I get the following in the verbose output:

<30 new auto-negotiating client connection
30: Client using the ascii protocol
....
<30 get template.cache.template_browse_gene_list.d41d8cd98f00b204e9800998ecf8427e
>30 END
<30 connection closed.

The connection closed line is displayed as soon as the page is returned, but after quite a wait. I think basically when the SQL is done, the connection closed message appears. So basically, nothing gets into memcached for this entry. Again, this worked with locmem.

Any thoughts?

Thanks.

Upvotes: 0

Views: 396

Answers (1)

OverClocked
OverClocked

Reputation: 1197

Found this... explains it...

memcache won't store key/value because the value is too big

Upvotes: 1

Related Questions