Add bookmark cache, replace get_bookmark code with call to get_thing.
This commit is contained in:
		
							parent
							
								
									1f7247dbe1
								
							
						
					
					
						commit
						b859dbd22a
					
				
					 2 changed files with 5 additions and 7 deletions
				
			
		|  | @ -148,6 +148,7 @@ DEFAULT_CONFIGURATION = { | ||||||
| 
 | 
 | ||||||
|     'cache_size': { |     'cache_size': { | ||||||
|         'album': 1000, |         'album': 1000, | ||||||
|  |         'bookmark': 100, | ||||||
|         'photo': 100000, |         'photo': 100000, | ||||||
|         'tag': 1000, |         'tag': 1000, | ||||||
|         'user': 200, |         'user': 200, | ||||||
|  |  | ||||||
|  | @ -270,15 +270,10 @@ class PDBAlbumMixin: | ||||||
| class PDBBookmarkMixin: | class PDBBookmarkMixin: | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         super().__init__() |         super().__init__() | ||||||
|  |         self._bookmark_cache = cacheclass.Cache() | ||||||
| 
 | 
 | ||||||
|     def get_bookmark(self, id): |     def get_bookmark(self, id): | ||||||
|         cur = self.sql.cursor() |         return self.get_thing_by_id('bookmark', id) | ||||||
|         cur.execute('SELECT * FROM bookmarks WHERE id == ?', [id]) |  | ||||||
|         fetch = cur.fetchone() |  | ||||||
|         if fetch is None: |  | ||||||
|             raise exceptions.NoSuchBookmark(id) |  | ||||||
|         bookmark = objects.Bookmark(self, fetch) |  | ||||||
|         return bookmark |  | ||||||
| 
 | 
 | ||||||
|     def get_bookmarks(self): |     def get_bookmarks(self): | ||||||
|         yield from self.get_things(thing_type='bookmark') |         yield from self.get_things(thing_type='bookmark') | ||||||
|  | @ -1181,11 +1176,13 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs | ||||||
|         self._cached_frozen_children = None |         self._cached_frozen_children = None | ||||||
| 
 | 
 | ||||||
|         self._album_cache.maxlen = self.config['cache_size']['album'] |         self._album_cache.maxlen = self.config['cache_size']['album'] | ||||||
|  |         self._bookmark_cache.maxlen = self.config['cache_size']['bookmark'] | ||||||
|         self._photo_cache.maxlen = self.config['cache_size']['photo'] |         self._photo_cache.maxlen = self.config['cache_size']['photo'] | ||||||
|         self._tag_cache.maxlen = self.config['cache_size']['tag'] |         self._tag_cache.maxlen = self.config['cache_size']['tag'] | ||||||
|         self._user_cache.maxlen = self.config['cache_size']['user'] |         self._user_cache.maxlen = self.config['cache_size']['user'] | ||||||
|         self.caches = { |         self.caches = { | ||||||
|             'album': self._album_cache, |             'album': self._album_cache, | ||||||
|  |             'bookmark': self._bookmark_cache, | ||||||
|             'photo': self._photo_cache, |             'photo': self._photo_cache, | ||||||
|             'tag': self._tag_cache, |             'tag': self._tag_cache, | ||||||
|             'user': self._user_cache, |             'user': self._user_cache, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue