remove unused list cache
This commit is contained in:
parent
ad6afd599e
commit
bc593b65fd
3 changed files with 0 additions and 38 deletions
|
@ -156,7 +156,6 @@ class Changelog(db.Model):
|
|||
if user not in i.users:
|
||||
i.add_user(user)
|
||||
i.update()
|
||||
user.clear_smart_list_cache()
|
||||
return True
|
||||
|
||||
def action_edititem(self, user, timestamp, itemid, meta):
|
||||
|
@ -194,7 +193,6 @@ class Changelog(db.Model):
|
|||
else:
|
||||
i.update_meta(meta, modified=i.modified)
|
||||
i.save()
|
||||
user.clear_smart_list_cache()
|
||||
return True
|
||||
|
||||
def action_removeitem(self, user, timestamp, itemid):
|
||||
|
@ -207,8 +205,6 @@ class Changelog(db.Model):
|
|||
i.update()
|
||||
else:
|
||||
i.delete()
|
||||
user.clear_list_cache()
|
||||
user.clear_smart_list_cache()
|
||||
return True
|
||||
|
||||
def action_addlist(self, user, timestamp, name, query=None):
|
||||
|
@ -224,7 +220,6 @@ class Changelog(db.Model):
|
|||
if 'name' in new:
|
||||
l.name = new['name']
|
||||
l.save()
|
||||
user.clear_list_cache()
|
||||
return True
|
||||
|
||||
def action_orderlists(self, user, timestamp, lists):
|
||||
|
@ -242,7 +237,6 @@ class Changelog(db.Model):
|
|||
l = List.get(user.id, name)
|
||||
if l:
|
||||
l.remove()
|
||||
user.clear_list_cache()
|
||||
return True
|
||||
|
||||
def action_addlistitems(self, user, timestamp, name, ids):
|
||||
|
@ -302,7 +296,6 @@ class Changelog(db.Model):
|
|||
m = Metadata.get_or_create(key, value)
|
||||
if m.edit(data, False):
|
||||
m.update_items()
|
||||
user.clear_smart_list_cache()
|
||||
return True
|
||||
|
||||
def action_resetmeta(self, user, timestamp, key, value):
|
||||
|
@ -310,5 +303,4 @@ class Changelog(db.Model):
|
|||
m = Metadata.get(key, value)
|
||||
if m and m.timestamp < timestamp:
|
||||
m.reset()
|
||||
user.clear_smart_list_cache()
|
||||
return True
|
||||
|
|
|
@ -34,7 +34,6 @@ else:
|
|||
|
||||
preferences = pdict(os.path.join(config_path, 'preferences.json'), config['user']['preferences'])
|
||||
ui = pdict(os.path.join(config_path, 'ui.json'), config['user']['ui'])
|
||||
list_cache = pdict(os.path.join(config_path, 'list_cache.json'), {})
|
||||
|
||||
server = pdict(os.path.join(config_path, 'server.json'))
|
||||
server_defaults = {
|
||||
|
|
|
@ -89,22 +89,6 @@ class User(db.Model):
|
|||
self.library
|
||||
return [l.json() for l in self.lists.order_by('index_')]
|
||||
|
||||
def clear_list_cache(self):
|
||||
if self.id == settings.USER_ID:
|
||||
prefix = ':'
|
||||
else:
|
||||
prefix = self.id + ':'
|
||||
for key in list(settings.list_cache):
|
||||
if key.startswith(prefix):
|
||||
del settings.list_cache[key]
|
||||
|
||||
def clear_smart_list_cache(self):
|
||||
qs = List.query.filter_by(type='smart')
|
||||
smart_lists = [':%d' % l.id for l in qs]
|
||||
for key in list(settings.list_cache):
|
||||
if key in smart_lists:
|
||||
del settings.list_cache[key]
|
||||
|
||||
def update_peering(self, peered, username=None):
|
||||
was_peering = self.peered
|
||||
if peered:
|
||||
|
@ -136,7 +120,6 @@ class User(db.Model):
|
|||
Changelog.query.filter_by(user_id=self.id).delete()
|
||||
if self.id in settings.ui['showFolder']:
|
||||
del settings.ui['showFolder'][self.id]
|
||||
self.clear_list_cache()
|
||||
self.save()
|
||||
if was_peering:
|
||||
Changelog.record(state.user(), 'removepeer', self.id)
|
||||
|
@ -263,8 +246,6 @@ class List(db.Model):
|
|||
state.db.session.commit()
|
||||
if self.user_id == settings.USER_ID and self.name != '':
|
||||
Changelog.record(self.user, 'addlistitems', self.name, items)
|
||||
self.user.clear_smart_list_cache()
|
||||
self.user.clear_list_cache()
|
||||
|
||||
def get_items(self):
|
||||
from item.models import Item
|
||||
|
@ -284,8 +265,6 @@ class List(db.Model):
|
|||
state.db.session.commit()
|
||||
if self.user_id == settings.USER_ID and self.name != '':
|
||||
Changelog.record(self.user, 'removelistitems', self.name, items)
|
||||
self.user.clear_smart_list_cache()
|
||||
self.user.clear_list_cache()
|
||||
|
||||
def remove(self):
|
||||
if not self._query:
|
||||
|
@ -318,13 +297,6 @@ class List(db.Model):
|
|||
|
||||
def items_count(self):
|
||||
return self.get_items().count()
|
||||
key = self.find_id
|
||||
if key in settings.list_cache:
|
||||
value = settings.list_cache[key]
|
||||
else:
|
||||
value = self.get_items().count()
|
||||
settings.list_cache[key] = value
|
||||
return value
|
||||
|
||||
def json(self):
|
||||
r = {
|
||||
|
@ -332,7 +304,6 @@ class List(db.Model):
|
|||
'user': self.user.name,
|
||||
'name': self.name,
|
||||
'index': self.index_,
|
||||
# to slow for many smart lists
|
||||
'items': self.items_count(),
|
||||
'type': self.type
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue