Skip to content

Conversation

federicobond
Copy link
Contributor

Description

This changes the values of the backend columns for cache calls in the Cache panel from <django.core.cache.backends.dummy.DummyCache object at 0x1063950a0> to default or the corresponding alias. This makes it much easier to identify which call is made to which backend when several cache backends share the same engine.

Before:

Captura de pantalla 2025-10-08 a la(s) 9 48 20

After:

Captura de pantalla 2025-10-08 a la(s) 9 49 26

Checklist:

  • I have added the relevant tests for this change.
  • I have added an item to the Pending section of docs/changes.rst.

@federicobond federicobond changed the title Show cache alias instead of backend repr Show cache alias instead of backend repr in calls table Oct 8, 2025
_monkey_patch_cache(cache)
cache._djdt_panel = self
for alias in caches:
if hasattr(caches._connections, alias):
Copy link
Member

@tim-schilling tim-schilling Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like it's going to be hard for us to remember that this is effectively the old version of initialized_only=True. Do you have any ideas on making this more maintainable? [Specifically if Django changes its implementation upstream.]

The only idea I have is to use a cache._djdt_panel.record = functools.partial(cache._djdt_panel.record, alias=alias)

Though it makes me wonder if we need the panel on the cache at all. Seems like we could just store a _djdt_record function on the cache, where then the partial gets much cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though it makes me wonder if we need the panel on the cache at all. Seems like we could just store a _djdt_record function on the cache, where then the partial gets much cleaner.

We do not need the panel on the cache in the current code, it's just used a monkeypatch marker.

The only idea I have is to use a cache._djdt_panel.record = functools.partial(cache._djdt_panel.record, alias=alias)

I thought about something similar, but it needed more changes to the panel inner workings so I went with the most straightforward implementation to validate interest first. I could try a similar approach, storing a _djdt_record function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants