Skip to content

add cache_dir - #41

Open
sn6uv wants to merge 8 commits into
alex:masterfrom
sn6uv:master
Open

add cache_dir#41
sn6uv wants to merge 8 commits into
alex:masterfrom
sn6uv:master

Conversation

@sn6uv

Copy link
Copy Markdown
Contributor

New Cache API

Comment threadrply/parsergenerator.py Outdated

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
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

alex commented Dec 26, 2014

Copy link
Copy Markdown
Owner

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
sn6uvforce-pushed the master branch 2 times, most recently from 20e987a to 903a9e9CompareJanuary 2, 2015 10:29
Comment threadtests/test_parsergenerator.py Outdated

Copy link
Copy Markdown
ContributorAuthor

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
sn6uvforce-pushed the master branch 3 times, most recently from 016f348 to c7b9e7eCompareJanuary 2, 2015 11:38
@sn6uv

sn6uv commented Jan 2, 2015

Copy link
Copy Markdown
ContributorAuthor

Working with the App engine #24 should be relatively simple. Something like the following (totally untested) code should work:

classAppEngineCache(object):
VERSION=1def__init__(self, cache_id):
self.cache_id=cache_iddef_get_key(self, grammar_hash):
return"rply-%s-%s-%s"% (self.VERSION, self.cache_id, grammar_hash)
defload(self, grammar_hash):
cache_key=self._get_key(grammar_hash)
memcache.get(cache_key, namespace="rply")
defdump(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
Copy Markdown
ContributorAuthor

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

sn6uv commented Feb 1, 2015

Copy link
Copy Markdown
ContributorAuthor

Any word on this PR?

@sn6uv

Copy link
Copy Markdown
ContributorAuthor

@alex any updates on this?

Sign up for freeto 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

@sn6uv@alex