#32749: PyMemcacheCache uses default_noreply=False although pymemcache
recommends
to set to True
-------------------------------------+-------------------------------------
Reporter: yakirsudry | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 3.2
Severity: Normal | Resolution:
Keywords: pymemcache | Triage Stage: Accepted
PyMemcacheCache |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Nick Pope):
* type: Bug => Cleanup/optimization
* component: Core (Cache system) => Documentation
* easy: 0 => 1
* stage: Unreviewed => Accepted
Comment:
Thank you for dredging up my comment Simon.
As mentioned there, I was trying to ensure that the new `pymemcache`
backend was compatible with the expectations of Django by
[https://github.com/django/django/blob/0851933cba7b40e22f5e424c95763dbc27c40aa9/django/core/cache/backends/memcached.py#L238-L240
setting various options].
If I remove `'default_noreply': False,` then a heap of tests fail because
`pymemcache` always returns `True` for some operations:
{{{
$ python runtests.py --settings=test_sqlite --parallel=1 --timing
cache.tests.PyMemcacheCacheTests
Testing against Django installed in '/home/pope1ni/Sources/django/django'
Found 58 tests.
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
F....F..F......ss.........F..F........................F.s.
======================================================================
FAIL: test_add (cache.tests.PyMemcacheCacheTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/pope1ni/Sources/django/tests/cache/tests.py", line 306, in
test_add
self.assertIs(cache.add("addkey1", "newvalue"), False)
AssertionError: True is not False
======================================================================
FAIL: test_cache_versioning_add (cache.tests.PyMemcacheCacheTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/pope1ni/Sources/django/tests/cache/tests.py", line 767, in
test_cache_versioning_add
self.assertIs(cache.add('answer1', 37, version=2), False)
AssertionError: True is not False
======================================================================
FAIL: test_cache_versioning_get_set_many
(cache.tests.PyMemcacheCacheTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/pope1ni/Sources/django/tests/cache/tests.py", line 900, in
test_cache_versioning_get_set_many
self.assertEqual(cache.get_many(['ford3', 'arthur3'], version=2),
{'ford3': 37, 'arthur3': 42})
AssertionError: {'ford3': 37} != {'ford3': 37, 'arthur3': 42}
- {'ford3': 37}
+ {'arthur3': 42, 'ford3': 37}
======================================================================
FAIL: test_delete_nonexistent (cache.tests.PyMemcacheCacheTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/pope1ni/Sources/django/tests/cache/tests.py", line 344, in
test_delete_nonexistent
self.assertIs(cache.delete('nonexistent_key'), False)
AssertionError: True is not False
======================================================================
FAIL: test_forever_timeout (cache.tests.PyMemcacheCacheTests)
Passing in None into timeout results in a value that is cached forever
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/pope1ni/Sources/django/tests/cache/tests.py", line 597, in
test_forever_timeout
self.assertIs(cache.add('key1', 'new eggs', None), False)
AssertionError: True is not False
======================================================================
FAIL: test_touch (cache.tests.PyMemcacheCacheTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/pope1ni/Sources/django/tests/cache/tests.py", line 484, in
test_touch
self.assertIs(cache.touch('nonexistent'), False)
AssertionError: True is not False
----------------------------------------------------------------------
Ran 58 tests in 12.032s
FAILED (failures=6, skipped=3)
Destroying test database for alias 'default'...
Total database setup took 0.090s
Creating 'default' took 0.090s
Total database teardown took 0.000s
Total run took 12.187s
}}}
It is perfectly possible for developers to add `'default_noreply': True,`
to their `OPTIONS` for the cache to override this.
I find it a strange default. Yes, it is faster, but probably less safe -
see the failure for `test_cache_versioning_get_set_many` above.
We can add an admonition to state what options are being set by default
for `pymemcache`, but I don't feel that we need to change the behaviour.
--
Ticket URL: <https://code.djangoproject.com/ticket/32749#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.4f0ad99a444dc4710bd05797b91eb976%40djangoproject.com.