django / django/new-features

DatabaseCache - Support batching in set_many

Open
#174 1 comment 5 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
188
Forks
7
PR merge metrics
No merged PRs in 30d

Description

### Code of Conduct

- [x] I agree to follow Django's Code of Conduct

### Feature Description

DatabaseCache currently supports `set_many`, by iterating each item one by one and saving. This can be a slow loop when saving many items, and would benefit from bulk creation of records, overriding the default.

### Problem

This will save time when saving multiple cache records. No other tangible benefit comes to mind.

### Request or proposal

proposal

### Additional Details

I'm happy to drop a pull request for this change, but this would be my first for this project so may make mistakes.

### Implementation Suggestions

I was thinking about just overriding the existing `set_cache` method on the DatabaseCache cache backend, bulk creating records instead of one at a time.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the DatabaseCache cache backend and reading its set_many and set_cache methods to understand the current per-item save behavior. Check the cache backend tests and existing bulk-operation conventions before changing the persistence path. Done means set_many stores multiple records through a bulk operation while preserving the existing cache behavior and passing the relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend, databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.