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

Deprecate using cache specific constructors #473

Open
argaen opened this issue Dec 24, 2019 · 3 comments
Open

Deprecate using cache specific constructors #473

argaen opened this issue Dec 24, 2019 · 3 comments

Comments

@argaen
Copy link
Member

argaen commented Dec 24, 2019

Cache class was introduced as a proxy for instantiating the different backends. There should be only one way of doing things and Cache is the preferred way of doing that so will deprecate the others

@argaen argaen added this to the 0.12.0 milestone Oct 15, 2020
padraic-shafer added a commit to padraic-shafer/aiocache that referenced this issue Apr 24, 2022
* See aio-libs#473: Deprecate using cache specific constructors
  * aio-libs#473
  * `Cache` class was introduced as a proxy for instantiating the different
    backends. There should be only one way of doing things and `Cache` is
    the preferred way of doing that so will deprecate the others.
* This is now applied to `cached._get_cache()`
@padraic-shafer
Copy link
Contributor

This should probably also apply to creating the cache inside the decorator @cached. It looks like this might have been overlooked.

def _get_cache(cache=Cache.MEMORY, serializer=None, plugins=None, **cache_kwargs):
return cache(serializer=serializer, plugins=plugins, **cache_kwargs)

PR #568 was submitted.

@Dreamsorcerer
Copy link
Member

This is an open issue, so doesn't look like anybody has deprecated anything yet.

@Dreamsorcerer
Copy link
Member

I'm not sure how well this'll play with static typing, so I suspect we'll have to change this again as we introduce typing to the library.

It seems slightly odd to me that we instantiate a wrapper class and pass the implementation class as an argument, rather than just using it directly. i.e. Why do Cache(Cache.MEMORY) and not just Cache.MEMORY() or SimpleMemoryCache()?

@Dreamsorcerer Dreamsorcerer removed this from the 0.12.0 milestone Jan 2, 2023
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

No branches or pull requests

3 participants