-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Cache: OrderedCache #23
Conversation
Looks good. Can you describe your use case? I've been interested in something similar. Though I wanted to define |
A cache for managing TCP requests when the app is offline (no network connection). All requests during this time consult the cache which should only store unique requests (the app may duplicate requests based on user input). Once network connection is restored the app will process the TCP requests in order to prevent starvation.
That sounds like a better, more Pythonic approach.
That works. Do you have the time to implement this if you have a design in mind? I don't mind doing it, though. |
If you have time, please do and I'll merge/deploy. The design should be pretty simple. I would use a generator and track the rowid. |
@grantjenks Please take a look. Also, not sure why the pypy build is failing. |
If you rerun the PyPy test it will work. There's a bug open for the scheme change error. |
You've also got to call disk.get to convert the database key to a python object. Also, can you do lookups in chunks rather than fetchall? Use the cull_limit for chunk size. |
…ed on disk chunk size
Thanks for the feedback, please take a look again. |
Looks good. Can you put that in a while loop to iterate all keys now? I'm a little concerned that iter may never end. Reversed will end at rowid 0 but if keys are added continuously then iter will keep going. You could reload the "count" attribute and use that to limit iteration. What do you think? |
Honestly, I don't think that is a problem. Doing our own magic to stop the iteration may be more convoluted than letting it continue on.
We could store the rowid and change the query to:
Same concept for reversed. Thoughts? |
Did you mean to merge that? |
Yep. I'll fix it up. I'm planning a new release tonight. |
Deployed at v1.7.0 to PyPI. I included only the iter and reversed addition to core.Cache. Use those to implement your first/last behavior. Thank you for your contribution. |
Awesome, thank you. |
I've found the need to query the cache based on order. If there is interest I can add more features.