Keep track of number of times search cache is cleared.

Allows external consumers of the db to maintain their own search caches.

Also make last_modified() a first class API.
This commit is contained in:
Kovid Goyal 2015-06-15 09:07:42 +05:30
parent 9f866e2ca8
commit c10ba11e30
2 changed files with 7 additions and 1 deletions

View File

@ -107,6 +107,7 @@ class Cache(object):
self.dirtied_cache = {}
self.dirtied_sequence = 0
self.cover_caches = set()
self.clear_search_cache_count = 0
# Implement locking for all simple read/write API methods
# An unlocked version of the method is stored with the name starting
@ -189,8 +190,13 @@ class Cache(object):
@write_api
def clear_search_caches(self, book_ids=None):
self.clear_search_cache_count += 1
self._search_api.update_or_clear(self, book_ids)
@read_api
def last_modified(self):
return self.backend.last_modified()
@write_api
def clear_caches(self, book_ids=None, template_cache=True, search_cache=True):
if template_cache:

View File

@ -121,7 +121,7 @@ class LibraryDatabase(object):
return self.backend.dbpath
def last_modified(self):
return self.backend.last_modified()
return self.new_api.last_modified()
def check_if_modified(self):
if self.last_modified() > self.last_update_check: