Skip to content

Commit def54f8

Browse files
committed
Use in-memory cache if dummy cache is set
1 parent 1db121b commit def54f8

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ After installation, you now need to redirect mail to the mail toolbar. Change y
5454
EMAIL_BACKEND = 'mail_panel.backend.MailToolbarBackend'
5555
```
5656

57-
**Important:** This plugin uses Django's cache backend to store messages. If you are using `DummyCache`, the mail panel will not work.
57+
**Important:** This plugin uses Django's cache backend to store messages. If you are using `DummyCache`, the mail panel will use a local memory cache, and will reset messages when the server is restarted.
5858

5959

6060
**[Optional]**
@@ -119,4 +119,4 @@ Like Django Mail Panel? Be sure to check out and support these other tools for
119119
**[Kubermagic](https://echodot.com/kubermagic/)** - Automate, and script away tedious kubectl commands with Kubermagic; a UI for developers, QA teams, and those starting to learn the ins-and-outs of Kubernetes.
120120

121121

122-
**[Red](https://echodot.com/red/)** - A visual and interactive Redis client, featuring live updating keys, an interactive console, pub/sub, lua script support and much more.
122+
**[Red](https://echodot.com/red/)** - A visual and interactive Redis client, featuring live updating keys, an interactive console, pub/sub, lua script support and much more.

mail_panel/utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
from django.core.cache import cache
1+
from django.core.cache import cache, caches
22

33
from .conf import MAIL_TOOLBAR_CACHE_KEY, MAIL_TOOLBAR_TTL
44

5+
# Use local memory cache if default cache is a DummyCache
6+
if caches.settings.get('default', {}).get('BACKEND', '').endswith('.DummyCache'):
7+
caches.settings['mail_panel'] = {
8+
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
9+
'LOCATION': 'mail-panel',
10+
}
11+
cache = caches.create_connection('mail_panel')
12+
13+
514
def load_outbox():
615
"""
716
Returns a dictionary of cached mail.

0 commit comments

Comments
 (0)