On Mar 9, 2009, at 1:13 PM, Wichert Akkerman wrote:

I was looking a bit at the memcache handling and noticed something odd:
all requests were repeated. For example:

<11 get tostyle4you.lib.helpers_image_url_by_id·scale=scale56·id=None
11 sending key tostyle4you.lib.helpers_image_url_by_id·scale=scale56·id=None
11 END
<11 get tostyle4you.lib.helpers_image_url_by_id·scale=scale56·id=None
11 sending key tostyle4you.lib.helpers_image_url_by_id·scale=scale56·id=None
11 END

I tracked the cause down to the get_value code from the Beaker
container, which looks like this:

222         def get_value(self):
223             self.namespace.acquire_read_lock()
224             try:
225                 has_value = self.has_value()
226  ->             if has_value:
227                     value = self.__get_value()

has_value and __get_value execute the same memcache get command, so a
cache hit always results in two identical queries.

Is there a reason Beaker can't roll has_value and get_value in one call?

It can, and it should for memcached. This is one of the things with trying to have a generic system that can store 'stuff' in 'containers' without knowing too much about specifics in the container. The system is built generically for different containers, while with memcached its better to just try and fetch a non-existent key as it's going to return None if its not there. Other backends will throw an exception though, so to try and be efficient, it does a has_key check first.

I've been thinking of ways to make the system more efficient so it can more effectively use the specific container, but I'm mainly focusing on Pylons right now. Perhaps you'd like to start looking into Beaker to see if there's some ways to make it better? :)

Cheers,
Ben

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to