diff options
author | Jay Hutchinson <jlhutch@gmail.com> | 2018-05-05 18:40:02 -0500 |
---|---|---|
committer | Jay Hutchinson <jlhutch@gmail.com> | 2018-05-06 11:12:21 -0500 |
commit | 7ec62efb9da433b679a924b26902b72e46371a24 (patch) | |
tree | f4de3764713611d616d02c1f0b15a2c3bebeeadf | |
parent | e09228909ef01df7bd6e94a7a66232be60ff85ee (diff) | |
download | pylru-7ec62efb9da433b679a924b26902b72e46371a24.tar.gz |
Added len() method to WriteBackCacheManager.
-rw-r--r-- | README.txt | 7 | ||||
-rw-r--r-- | pylru.py | 4 |
2 files changed, 11 insertions, 0 deletions
@@ -183,6 +183,13 @@ Similar to the WriteThroughCacheManager class except write-back semantics are us cached.size(x) # Changes the size of the cache. x MUST be greater than # zero. Returns the new size x. + x = len(cached) # Returns the number of items stored in the store. + # + # WARNING - This method calls sync() internally. If + # that has adverse performance effects for your + # application, you may want to avoid calling this + # method frequently. + cached.clear() # Remove all items from the store and cache. cached.sync() # Make the store and cache consistent. Write all @@ -370,6 +370,10 @@ class WriteBackCacheManager(object): def size(self, size=None): return self.cache.size(size) + def len(self): + self.sync() + return len(self.store) + def clear(self): self.cache.clear() self.dirty.clear() |