Opened 2 years ago

Closed 2 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: master
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:2 Changed 2 years ago by Carlton Gibson

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

This seems reasonable given #29584.
(Possibly merge the two tickets?)

Last edited 2 years ago by Carlton Gibson (previous) (diff)

comment:4 Changed 2 years ago by Tim Graham

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: AcceptedReady for checkin

comment:5 Changed 2 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In abd0ad76:

Fixed #29626, #29584 -- Added optimized versions of get_many() and delete_many() for the db cache backend.

Note: See TracTickets for help on using tickets.
Back to Top