• Vincent Pelletier's avatar
    MemcachedTool: Pool memcache.Client instances · 6bd5cf37
    Vincent Pelletier authored
    Unlike other database adaptors, memcache adaptors can be shared among
    transactions. So pool them in order to reduce the number of connections
    established to memcached servers. And as the connections handle
    thread-safety internally (by inheriting from threading.local), threads
    can share the same connection instance.
    Also, do not create a new connector each time we get disconnected, just
    reconnect.
    Also, memcached internally retries connection, so no need to retry it
    ourselves.
    Also, do not log when failing to update & delete entries in cache
    server: this is a racy cache, each read much be checked anyway, so
    failed writes are just business as usual.
    Also, document a bit more why we catch "any" exception happening during
    finish, and specify base exception class following python coding best
    practices.
    Also, use named constant for loggin levels for remaining log directives.
    Also, display traceback when catching a connection issue during
    __getitem__, as the original exception gets converted into a KeyError.
    6bd5cf37
MemcachedTool.py 11.5 KB