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

Fail to use ProxyBackend with dbm backend #202

Closed
zhsj opened this issue May 20, 2021 · 3 comments
Closed

Fail to use ProxyBackend with dbm backend #202

zhsj opened this issue May 20, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@zhsj
Copy link

zhsj commented May 20, 2021

Not sure if I missed something, but following example is changed from user doc.

from dogpile.cache import make_region
from dogpile.cache.proxy import ProxyBackend
import logging

log = logging.getLogger(__name__)


class LoggingProxy(ProxyBackend):
    def set(self, key, value):
        log.debug("Setting Cache Key: %s" % key)
        self.proxied.set(key, value)


region = make_region().configure(
    "dogpile.cache.dbm",
    expiration_time=3600,
    arguments={
        "filename": "/tmp/cache",
    },
    wrap=[LoggingProxy],
)
region.get("k")
Traceback (most recent call last):
  File "/tmp/t/dogpile/test.py", line 22, in <module>
    region.get("k")
  File "/tmp/t/dogpile/env/lib/python3.9/site-packages/dogpile/cache/region.py", line 765, in get
    value = self._get_from_backend(key)
  File "/tmp/t/dogpile/env/lib/python3.9/site-packages/dogpile/cache/region.py", line 1265, in _get_from_backend
    self.backend.get_serialized(key)
  File "/tmp/t/dogpile/env/lib/python3.9/site-packages/dogpile/cache/api.py", line 288, in get_serialized
    return cast(SerializedReturnType, self.get(key))
  File "/tmp/t/dogpile/env/lib/python3.9/site-packages/dogpile/cache/proxy.py", line 85, in get
    return self.proxied.get(key)
  File "/tmp/t/dogpile/env/lib/python3.9/site-packages/dogpile/cache/api.py", line 245, in get
    raise NotImplementedError()
NotImplementedError

env

$ pip list
Package       Version
------------- -------
decorator     5.0.9
dogpile.cache 1.1.2
pbr           5.6.0
pip           20.3.4
pkg-resources 0.0.0
setuptools    44.1.1
stevedore     3.3.0
@zzzeek
Copy link
Member

zzzeek commented May 20, 2021

this is a regression, proxybackend is missing several methods.

@zzzeek zzzeek added the bug Something isn't working label May 20, 2021
@sqla-tester
Copy link
Collaborator

Mike Bayer has proposed a fix for this issue in the master branch:

Add missing methods to ProxyBackend https://gerrit.sqlalchemy.org/c/sqlalchemy/dogpile.cache/+/2831

@zhsj
Copy link
Author

zhsj commented May 20, 2021

Thanks for the quick fix, I can confirm it fixes the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants