mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #32772 -- Made database cache count size once per set.
This commit is contained in:
parent
12b19a1d76
commit
5a8e8f80bb
3 changed files with 20 additions and 6 deletions
13
tests/cache/tests.py
vendored
13
tests/cache/tests.py
vendored
|
@ -40,6 +40,7 @@ from django.test import (
|
|||
ignore_warnings, override_settings,
|
||||
)
|
||||
from django.test.signals import setting_changed
|
||||
from django.test.utils import CaptureQueriesContext
|
||||
from django.utils import timezone, translation
|
||||
from django.utils.cache import (
|
||||
get_cache_key, learn_cache_key, patch_cache_control, patch_vary_headers,
|
||||
|
@ -1117,6 +1118,18 @@ class DBCacheTests(BaseCacheTests, TransactionTestCase):
|
|||
with self.assertNumQueries(1):
|
||||
cache.delete_many(['a', 'b', 'c'])
|
||||
|
||||
def test_cull_count_queries(self):
|
||||
old_max_entries = cache._max_entries
|
||||
# Force _cull to delete on first cached record.
|
||||
cache._max_entries = -1
|
||||
with CaptureQueriesContext(connection) as captured_queries:
|
||||
try:
|
||||
cache.set('force_cull', 'value', 1000)
|
||||
finally:
|
||||
cache._max_entries = old_max_entries
|
||||
num_count_queries = sum('COUNT' in query['sql'] for query in captured_queries)
|
||||
self.assertEqual(num_count_queries, 1)
|
||||
|
||||
def test_delete_cursor_rowcount(self):
|
||||
"""
|
||||
The rowcount attribute should not be checked on a closed cursor.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue