Skip to content
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

Add Google Cloud Storage Cache #214

Merged
merged 10 commits into from
Mar 6, 2021
Merged

Add Google Cloud Storage Cache #214

merged 10 commits into from
Mar 6, 2021

Conversation

oittaa
Copy link
Contributor

@oittaa oittaa commented Feb 3, 2021

This is useful in cloud environments where shared disk cache doesn't exist, but the computation takes a lot of resources and the resulted data doesn't fit easily in Memcached or Redis.

I used an abandoned S3 pull request as a starting point. pallets-eco/cachelib#6

@coveralls
Copy link

coveralls commented Feb 3, 2021

Coverage Status

Coverage increased (+0.4%) to 79.608% when pulling 2e492cd on oittaa:master into f1899bc on sh4nks:master.

@oittaa
Copy link
Contributor Author

oittaa commented Feb 4, 2021

All tests passed with my test server.

GCS_BUCKET=my-test-bucket python3 -m pytest

tests/test_backend_cache.py::TestGoogleCloudStorageCache::test_generic_get_dict PASSED                                                                                                     [ 56%]
tests/test_backend_cache.py::TestGoogleCloudStorageCache::test_generic_set_get PASSED                                                                                                      [ 56%]
tests/test_backend_cache.py::TestGoogleCloudStorageCache::test_generic_get_set PASSED                                                                                                      [ 57%]
tests/test_backend_cache.py::TestGoogleCloudStorageCache::test_generic_get_many PASSED                                                                                                     [ 57%]
tests/test_backend_cache.py::TestGoogleCloudStorageCache::test_generic_set_many PASSED                                                                                                     [ 58%]
tests/test_backend_cache.py::TestGoogleCloudStorageCache::test_generic_add PASSED                                                                                                          [ 58%]
tests/test_backend_cache.py::TestGoogleCloudStorageCache::test_generic_delete PASSED                                                                                                       [ 59%]
tests/test_backend_cache.py::TestGoogleCloudStorageCache::test_generic_delete_many PASSED                                                                                                  [ 59%]
tests/test_backend_cache.py::TestGoogleCloudStorageCache::test_generic_inc_dec PASSED                                                                                                      [ 60%]
tests/test_backend_cache.py::TestGoogleCloudStorageCache::test_generic_true_false PASSED                                                                                                   [ 60%]
tests/test_backend_cache.py::TestGoogleCloudStorageCache::test_generic_timeout PASSED                                                                                                      [ 61%]
tests/test_backend_cache.py::TestGoogleCloudStorageCache::test_generic_has PASSED                                                                                                          [ 61%]

@oittaa
Copy link
Contributor Author

oittaa commented Feb 4, 2021

For better code coverage you'll need to configure proper Cloud Storage support to your Travis instance.

@sh4nks
Copy link
Collaborator

sh4nks commented Mar 4, 2021

Hi @oittaa, could you rebase your PR against current master and move your backend to flask_caching.contrib?

@oittaa
Copy link
Contributor Author

oittaa commented Mar 4, 2021

Sure thing!

@oittaa
Copy link
Contributor Author

oittaa commented Mar 4, 2021

Please, tell me if something needs to be changed, but this pull request should be rebased now.

Copy link
Collaborator

@sh4nks sh4nks left a comment

Choose a reason for hiding this comment

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

I made some comments on your PR. Would be cool if you could address the issues I have with this PR.

flask_caching/backends/__init__.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
requirements.txt Outdated Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
@oittaa
Copy link
Contributor Author

oittaa commented Mar 5, 2021

Removed. You still might want to add a test like I had before. For example JSON can't handle byte strings and they need to be handled as a special case.

    def test_generic_get_binary(self, c):
        assert c.set("foo", b"bar")
        assert c.get("foo") == b"bar"

@sh4nks
Copy link
Collaborator

sh4nks commented Mar 6, 2021

Removed. You still might want to add a test like I had before. For example JSON can't handle byte strings and they need to be handled as a special case.

    def test_generic_get_binary(self, c):
        assert c.set("foo", b"bar")
        assert c.get("foo") == b"bar"

Feel free to open a new PR for this!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants