Opened 6 years ago
Closed 6 years ago
#29626 closed Cleanup/optimization (fixed)
Implement an optimized version of delete_many() for the db cache backend
Reported by: | oliver | Owned by: | nobody |
---|---|---|---|
Component: | Core (Cache system) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Now delete_many() in core.backends.base.BaseCache is as follows.
def delete_many(self, keys, version=None): """ Delete a bunch of values in the cache at once. For certain backends (memcached), this is much more efficient than calling delete() multiple times. """ for key in keys: self.delete(key, version=version)
And cache.backends.db does not implement delete_many()
So if i retrieve 100 entries from the db cache, 100 queries are executed instead of just one
It should be fixed
This ticket is similar to https://code.djangoproject.com/ticket/29584
Change History (5)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
This seems reasonable given #29584.
(Possibly merge?)
comment:3 by , 6 years ago
https://github.com/django/django/pull/10257
I rebased https://github.com/django/django/pull/10257 's branch onto https://github.com/django/django/pull/10258 's branch.
So i think that just https://github.com/django/django/pull/10257 needs to be merged.
comment:4 by , 6 years ago
Patch needs improvement: | unset |
---|---|
Summary: | cache.backends.db does not implement delete_many() → Implement an optimized version of delete_many() for the db cache backend |
Triage Stage: | Accepted → Ready for checkin |
https://github.com/django/django/pull/10258