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 Cache factory #430

Merged
merged 5 commits into from
Jan 4, 2019
Merged

Add Cache factory #430

merged 5 commits into from
Jan 4, 2019

Conversation

argaen
Copy link
Member

@argaen argaen commented Dec 31, 2018

Adds aiocache.Cache as a factory for creating different caches. Previously you would have to import the specific backend as

from aiocache import RedisCache

cache = RedisCache

now

from aiocache import Cache

cache = Cache(Cache.REDIS)

it just adds a level of indirection but will help on adding/centralizing features like creating a cache from a resource url, creating from a string for the config, etc. Also recommending this approach to create caches from now on

@argaen argaen force-pushed the feature_#428/cache_class_factory branch from 1db6b7f to 61ad59c Compare December 31, 2018 16:00
@codecov
Copy link

codecov bot commented Dec 31, 2018

Codecov Report

Merging #430 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #430      +/-   ##
==========================================
+ Coverage   99.77%   99.77%   +<.01%     
==========================================
  Files           9       10       +1     
  Lines         873      894      +21     
  Branches       96       96              
==========================================
+ Hits          871      892      +21     
  Misses          2        2
Impacted Files Coverage Δ
aiocache/lock.py 100% <ø> (ø) ⬆️
aiocache/serializers.py 96.49% <ø> (ø) ⬆️
aiocache/exceptions.py 100% <100%> (ø)
aiocache/factory.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 699db4e...fb181e6. Read the comment docs.

@codecov
Copy link

codecov bot commented Dec 31, 2018

Codecov Report

Merging #430 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #430      +/-   ##
==========================================
+ Coverage   99.77%   99.77%   +<.01%     
==========================================
  Files           9        9              
  Lines         873      882       +9     
  Branches       96       96              
==========================================
+ Hits          871      880       +9     
  Misses          2        2
Impacted Files Coverage Δ
aiocache/lock.py 100% <ø> (ø) ⬆️
aiocache/serializers.py 96.49% <ø> (ø) ⬆️
aiocache/decorators.py 100% <100%> (ø) ⬆️
aiocache/factory.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 699db4e...61ad59c. Read the comment docs.

@argaen
Copy link
Member Author

argaen commented Dec 31, 2018

@tomchristie the idea after this is to add a Cache.from_url that would instantiate a cache from a resource url. What do you think?

@tomchristie
Copy link

Yup good stuff! I guess ultimately I'd prefer Cache("redis://localhost/0") over Cache.from_url("redis://localhost/0") but either way this change helps make that possible.

👍

@argaen argaen force-pushed the feature_#428/cache_class_factory branch from 0414495 to fb181e6 Compare January 4, 2019 14:13
@argaen argaen merged commit a7ce588 into master Jan 4, 2019
@argaen argaen deleted the feature_#428/cache_class_factory branch January 4, 2019 16:17
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.

None yet

2 participants