masperro / httplib2

Automatically exported from code.google.com/p/httplib2
0 stars 0 forks source link

Patch for /python2/httplib2/__init__.py #238

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Some systems (such as GAE) have a limit on how large a single cache object can 
be. Adding a parameter for the maximum cache object size should be added.

Original issue reported on code.google.com by someone1@gmail.com on 5 Dec 2012 at 8:12

Attachments:

GoogleCodeExporter commented 8 years ago
This functionality doesn't belong in httplib2. You could create a wrapper for 
memcache that did the limiting:

from google.appengine.api.memcache

class SizeLimitedMemCache(object):
  def set(key, value, time=0, min_compress_len=0, namespace=None):
    if len(value) < 1000000:
      return memcache.set(key, value, time, min_compress_len, namespace)
    else:
      return False

  def get(key, namespace=None, for_cas=False):
    return memecache.get(key, namespace, for_cas)

  def delete(key, seconds=0, namespace=None):
    return memcache.delete(key, seconds, namespace)

Original comment by jcgregorio@google.com on 5 Dec 2012 at 10:51

GoogleCodeExporter commented 8 years ago
The better solution is to wrap the GAE cache with a layer that nicely rejects 
items that are too large.

Original comment by joe.gregorio@gmail.com on 13 Oct 2013 at 3:05