summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authoroliver <myungsekyo@gmail.com>2018-08-02 14:20:46 +0900
committerTim Graham <timograham@gmail.com>2018-08-17 15:13:09 -0400
commitabd0ad7681422d7c40a5ed12cc3c9ffca6b88422 (patch)
treeeadafa88a90ba15b7005f0f729667e039b5f4878 /tests
parentc02d473781dc2e8699db8edd37cc77f7d43993fc (diff)
Fixed #29626, #29584 -- Added optimized versions of get_many() and delete_many() for the db cache backend.
Diffstat (limited to 'tests')
-rw-r--r--tests/cache/tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py
index a101639f49..6578eb288f 100644
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -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)