Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sn6uv
Copy link
Contributor

@sn6uv sn6uv commented Dec 25, 2014

New Cache API

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to add an isinstance(cache_dir, basestring) check before the isdir call but this doesn't seem to behave nicely with RPython. Any suggestions?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is basestring really the correct type for paths? I think we should just pick unicode or bytes, whichever is correct, and use that.

@alex
Copy link
Owner

alex commented Dec 26, 2014

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.

@sn6uv sn6uv force-pushed the master branch 2 times, most recently from 20e987a to 903a9e9 Compare January 2, 2015 10:29
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be problematic, that is, on Travis in particular.

@sn6uv sn6uv force-pushed the master branch 3 times, most recently from 016f348 to c7b9e7e Compare January 2, 2015 11:38
@sn6uv
Copy link
Contributor Author

sn6uv commented Jan 2, 2015

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)

@sn6uv
Copy link
Contributor Author

sn6uv commented Jan 15, 2015

This conflicted with my other changes (in docs), so I've rebased on master.

I think this is ready now

    caching still occurs when no cache_id is specified but is not persistent between restarts
@sn6uv
Copy link
Contributor Author

sn6uv commented Feb 1, 2015

Any word on this PR?

@sn6uv
Copy link
Contributor Author

sn6uv commented Jun 21, 2015

@alex any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants