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

Mongo cache syntax isn't working. #30

Open
chengguangnan opened this issue Jun 13, 2016 · 0 comments
Open

Mongo cache syntax isn't working. #30

chengguangnan opened this issue Jun 13, 2016 · 0 comments

Comments

@chengguangnan
Copy link

I need to use this code:

# enable sunlight cache
setattr(sunlight.config, 'MONGO_HOST', C.Mgr.MONGO_HOST)
sunlight.cache.response_cache = sunlight.cache.MongoBackend()

The code in the document will throw exception:

import logging
from sunlight import response_cache
response_cache.enable('mongo')
response_cache.logger.setLevel(logging.DEBUG)

Exception:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/home/chengguangnan/anaconda3/lib/python3.5/site-packages/sunlight/cache.py in set_backend(self, backend_name)
    107         try:
--> 108             self.backend = backends[backend_name]()
    109             self.logger.info('Changed cache backend to %r.' % self.backend)

KeyError: 'mongo'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-24-2766d9958dbe> in <module>()
      1 import logging
      2 from sunlight import response_cache
----> 3 response_cache.enable('mongo')
      4 response_cache.logger.setLevel(logging.DEBUG)

/home/chengguangnan/anaconda3/lib/python3.5/site-packages/sunlight/cache.py in set_backend(self, backend_name)
    109             self.logger.info('Changed cache backend to %r.' % self.backend)
    110         except KeyError:
--> 111             raise ValueError('No backend named %r is defined.' % backend_name)
    112 
    113     enable = set_backend

ValueError: No backend named 'mongo' is defined.
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

1 participant