-
Notifications
You must be signed in to change notification settings - Fork 16
Conversation
@leplatrem I'm getting |
It looks perfectly correct. But when test are ran:
I also get this error:
That's because the tests setup do not use DEFAULT_SETTINGS. |
@leplatrem I have fixed this KeyError by |
Nope actually. You should leave Here is a small list of things to do before this could be merged:
|
@lavish205 you could do something like that (I didn't test it): def test_get_uses_prefix(self):
settings_prefix = self.settings.copy()
settings_prefix['cache_prefix'] = 'prefix_'
config_prefix = self._get_config(settings=settings_prefix)
# Instantiate a cache backend with a prefix:
backend_prefix = self.backend.load_from_config(config_prefix)
# Set a value with a cache that has no prefix:
self.cache.set('prefix_key', 'foo')
# Obtain the value with the cache that has a prefix:
obtained = backend_prefix.get('key')
self.assertEqual(obtained, 'foo') |
@leplatrem I think something is wrong with the code as test cases are not working as expected. |
@lavish205 yes, first you shouldn't set the prefix to Then, in order to make tests pass, you should use the |
@leplatrem value of |
backend_prefix.set('prefix_key', 'foo') | ||
|
||
# obtain the value of cache that has prefix | ||
obtained = backend_prefix.get('prefix_key') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be get('key')
since this backend has prefix prefix_
!
40c3ffd
to
4c7d7b9
Compare
@leplatrem can you please check, if there is need to add more test cases? |
@@ -25,20 +26,24 @@ def flush(self): | |||
self._store = {} | |||
|
|||
def ttl(self, key): | |||
key = self.prefix + key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather use format here: key = "{}{}".format(self.prefix, key)
or key = "%s%s" % (self.prefix, key)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ?
That's a great job @lavish205 👍 Thank you for working on it :) |
@leplatrem what to update in configuration documentation? |
@lavish205 I believe it is just about adding the
|
@Natim what exactly I have write under "What does it do?" column ? |
@lavish205 Something like: |
@@ -10,6 +10,7 @@ This document describes changes between each past release. | |||
**New features** | |||
|
|||
- Default console log renderer now has colours (#671) | |||
- ``Prefix`` key option added for cache. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setting is called cache_prefix
no?
I have added some documentation and a test to make sure Thank you @lavish205 for your work on this. |
Add cache_prefix setting (fixes #227)
Congrats @lavish205 for keeping the faith and going through all this! Thank you for getting involved with patience ! |
Thanks to both of you @leplatrem @Natim :) |
issue #227