mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #29626, #29584 -- Added optimized versions of get_many() and delete_many() for the db cache backend.
This commit is contained in:
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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user