mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
9f866e2ca8
commit
c10ba11e30
@ -107,6 +107,7 @@ class Cache(object):
|
|||||||
self.dirtied_cache = {}
|
self.dirtied_cache = {}
|
||||||
self.dirtied_sequence = 0
|
self.dirtied_sequence = 0
|
||||||
self.cover_caches = set()
|
self.cover_caches = set()
|
||||||
|
self.clear_search_cache_count = 0
|
||||||
|
|
||||||
# Implement locking for all simple read/write API methods
|
# Implement locking for all simple read/write API methods
|
||||||
# An unlocked version of the method is stored with the name starting
|
# An unlocked version of the method is stored with the name starting
|
||||||
@ -189,8 +190,13 @@ class Cache(object):
|
|||||||
|
|
||||||
@write_api
|
@write_api
|
||||||
def clear_search_caches(self, book_ids=None):
|
def clear_search_caches(self, book_ids=None):
|
||||||
|
self.clear_search_cache_count += 1
|
||||||
self._search_api.update_or_clear(self, book_ids)
|
self._search_api.update_or_clear(self, book_ids)
|
||||||
|
|
||||||
|
@read_api
|
||||||
|
def last_modified(self):
|
||||||
|
return self.backend.last_modified()
|
||||||
|
|
||||||
@write_api
|
@write_api
|
||||||
def clear_caches(self, book_ids=None, template_cache=True, search_cache=True):
|
def clear_caches(self, book_ids=None, template_cache=True, search_cache=True):
|
||||||
if template_cache:
|
if template_cache:
|
||||||
|
@ -121,7 +121,7 @@ class LibraryDatabase(object):
|
|||||||
return self.backend.dbpath
|
return self.backend.dbpath
|
||||||
|
|
||||||
def last_modified(self):
|
def last_modified(self):
|
||||||
return self.backend.last_modified()
|
return self.new_api.last_modified()
|
||||||
|
|
||||||
def check_if_modified(self):
|
def check_if_modified(self):
|
||||||
if self.last_modified() > self.last_update_check:
|
if self.last_modified() > self.last_update_check:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user