summaryrefslogtreecommitdiff
path: root/tests/cache/tests.py
diff options
context:
space:
mode:
authorvishwa <vis.pypi@gmail.com>2026-06-07 10:16:27 -0400
committerJacob Walls <jacobtylerwalls@gmail.com>2026-06-09 14:53:30 -0400
commit867c7c0451f2e67e715da5b55b5bf6696747fdc3 (patch)
tree345022c46e5863b239281761371b9efe3202bcdb /tests/cache/tests.py
parentbfb8679bd95e9387b848ef856e8eb6f1a4a4bac5 (diff)
Fixed #37130 -- Skipped DB cache deletion when culling offset is zero.
Diffstat (limited to 'tests/cache/tests.py')
-rw-r--r--tests/cache/tests.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py
index 4bc3e1e9ce..6ccc8f2a3e 100644
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -1361,6 +1361,24 @@ class DBCacheTests(BaseCacheTests, TransactionTestCase):
)
self.assertEqual(num_count_queries, 0)
+ def test_delete_query_skipped_on_high_cull_frequency(self):
+ cull_delete_cache = caches["cull"]
+ old_cull_freq = cull_delete_cache._cull_frequency
+
+ # CULL_FREQUENCY > MAX_ENTRIES forces
+ # (remaining_num // CULL_FREQUENCY) to evaluate to zero (cull_num)
+ cull_delete_cache._cull_frequency = cull_delete_cache._max_entries * 2
+ self.addCleanup(setattr, cull_delete_cache, "_cull_frequency", old_cull_freq)
+
+ self._perform_cull_test("cull", 50, 49)
+
+ with CaptureQueriesContext(connection) as captured_queries:
+ cull_delete_cache.set("force_cull", "value")
+
+ # Only the expiration DELETE query runs; culling is skipped.
+ num_delete_queries = sum("DELETE" in query["sql"] for query in captured_queries)
+ self.assertEqual(num_delete_queries, 1)
+
def test_delete_cursor_rowcount(self):
"""
The rowcount attribute should not be checked on a closed cursor.