fix group cache
This commit is contained in:
parent
6d659b8049
commit
0a4689387b
3 changed files with 8 additions and 3 deletions
|
@ -23,3 +23,8 @@ class Cache(dict):
|
||||||
if key in self._added:
|
if key in self._added:
|
||||||
del self._added[key]
|
del self._added[key]
|
||||||
del self[key]
|
del self[key]
|
||||||
|
|
||||||
|
def clear(self, prefix):
|
||||||
|
for key in list(self):
|
||||||
|
if key.startswith(prefix):
|
||||||
|
self.delete(key)
|
||||||
|
|
|
@ -140,9 +140,7 @@ def edit(data):
|
||||||
if len(ids) > 1:
|
if len(ids) > 1:
|
||||||
response = data
|
response = data
|
||||||
response['id'] = edited
|
response['id'] = edited
|
||||||
for key in list(state.cache):
|
state.cache.clear('group:')
|
||||||
if key.startswith('group:'):
|
|
||||||
state.cache.delete(key)
|
|
||||||
return response
|
return response
|
||||||
actions.register(edit, cache=False)
|
actions.register(edit, cache=False)
|
||||||
|
|
||||||
|
|
|
@ -233,6 +233,7 @@ def addListItems(data):
|
||||||
l = models.List.get_or_create(data['list'])
|
l = models.List.get_or_create(data['list'])
|
||||||
if l:
|
if l:
|
||||||
l.add_items(data['items'])
|
l.add_items(data['items'])
|
||||||
|
state.cache.clear('group:')
|
||||||
return l.json()
|
return l.json()
|
||||||
return {}
|
return {}
|
||||||
actions.register(addListItems, cache=False)
|
actions.register(addListItems, cache=False)
|
||||||
|
@ -248,6 +249,7 @@ def removeListItems(data):
|
||||||
l = models.List.get(data['list'])
|
l = models.List.get(data['list'])
|
||||||
if l:
|
if l:
|
||||||
l.remove_items(data['items'])
|
l.remove_items(data['items'])
|
||||||
|
state.cache.clear('group:')
|
||||||
return l.json()
|
return l.json()
|
||||||
return {}
|
return {}
|
||||||
actions.register(removeListItems, cache=False)
|
actions.register(removeListItems, cache=False)
|
||||||
|
|
Loading…
Reference in a new issue