Skip to content

Commit e1bedb8

Browse files
abhi1693jeremystretch
authored andcommitted
restores config revision during cache clear #14182
1 parent dd5e20a commit e1bedb8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
from django.core.cache import cache
22
from django.core.management.base import BaseCommand
33

4+
from extras.models import ConfigRevision
5+
46

57
class Command(BaseCommand):
68
"""Command to clear the entire cache."""
79
help = 'Clears the cache.'
810

911
def handle(self, *args, **kwargs):
12+
# Fetch the current config revision from the cache
13+
config_version = cache.get('config_version')
14+
# Clear the cache
1015
cache.clear()
1116
self.stdout.write('Cache has been cleared.', ending="\n")
17+
if config_version:
18+
# Activate the current config revision
19+
ConfigRevision.objects.get(id=config_version).activate()
20+
self.stdout.write(f'Config revision ({config_version}) has been restored.', ending="\n")

0 commit comments

Comments
 (0)