Open sn6uv opened 9 years ago
I'd kind of prefer to come up with a better API, e.g. cache=DirectoryCache("path")
, with the default being DirectoryCache(tmpdir)
, that way someone can write the AppEngine cache or whatever else they asked for in another issue.
Working with the App engine #24 should be relatively simple. Something like the following (totally untested) code should work:
class AppEngineCache(object):
VERSION=1
def __init__(self, cache_id):
self.cache_id = cache_id
def _get_key(self, grammar_hash):
return "rply-%s-%s-%s" % (self.VERSION, self.cache_id, grammar_hash)
def load(self, grammar_hash):
cache_key = self._get_key(grammar_hash)
memcache.get(cache_key, namespace="rply")
def dump(self, grammar_hash, data):
cache_key = self._get_key(grammar_hash)
memcache.set(cache_key, data, namespace="rply")
cache = AppEngineCache('myid')
ParserGenerator(["VALUE"], cache=cache)
This conflicted with my other changes (in docs), so I've rebased on master.
I think this is ready now
Any word on this PR?
@alex any updates on this?
New Cache API