Skip to content

Commit 7bd9e8f

Browse files
committed
Update comments
1 parent d9e8834 commit 7bd9e8f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

django_mongodb_backend/cache.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ def _cull(self, num):
125125
else:
126126
keep_num = num - num // self._cull_frequency
127127
try:
128-
# Delete from the first expiration date.
128+
# Find the first entry beyond the retention limit,
129+
# prioritizing earlier expiration dates.
129130
deleted_from = next(
130131
self.collection_for_write.aggregate(
131132
[
@@ -137,10 +138,12 @@ def _cull(self, num):
137138
)
138139
)
139140
except StopIteration:
140-
# Empty result, nothing to delete.
141+
# No entries found beyond the retention limit, nothing to delete.
141142
pass
142143
else:
143-
# Remove from key.
144+
# Delete all entries with an earlier expiration date.
145+
# If multiple entries share the same expiration date,
146+
# delete those with a greater or equal key.
144147
self.collection_for_write.delete_many(
145148
{
146149
"$or": [

0 commit comments

Comments
 (0)