mirror of
https://github.com/django/django.git
synced 2025-11-25 21:22:14 +00:00
Fixed #29626, #29584 -- Added optimized versions of get_many() and delete_many() for the db cache backend.
This commit is contained in:
parent
c02d473781
commit
abd0ad7681
2 changed files with 67 additions and 33 deletions
14
tests/cache/tests.py
vendored
14
tests/cache/tests.py
vendored
|
|
@ -1005,6 +1005,20 @@ class DBCacheTests(BaseCacheTests, TransactionTestCase):
|
|||
table_name = connection.ops.quote_name('test cache table')
|
||||
cursor.execute('DROP TABLE %s' % table_name)
|
||||
|
||||
def test_get_many_num_queries(self):
|
||||
cache.set_many({'a': 1, 'b': 2})
|
||||
cache.set('expired', 'expired', 0.01)
|
||||
with self.assertNumQueries(1):
|
||||
self.assertEqual(cache.get_many(['a', 'b']), {'a': 1, 'b': 2})
|
||||
time.sleep(0.02)
|
||||
with self.assertNumQueries(2):
|
||||
self.assertEqual(cache.get_many(['a', 'b', 'expired']), {'a': 1, 'b': 2})
|
||||
|
||||
def test_delete_many_num_queries(self):
|
||||
cache.set_many({'a': 1, 'b': 2, 'c': 3})
|
||||
with self.assertNumQueries(1):
|
||||
cache.delete_many(['a', 'b', 'c'])
|
||||
|
||||
def test_zero_cull(self):
|
||||
self._perform_cull_test(caches['zero_cull'], 50, 18)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue