Vitor de Lima has posted comments on this change.
Change subject: cache: Add caching decorator with invalidation
......................................................................
Patch Set 4:
(3 comments)
http://gerrit.ovirt.org/#/c/34709/4/lib/vdsm/cache.py
File lib/vdsm/cache.py:
Line 42: """
Line 43: Return a caching decorator supporting invalidation.
Line 44:
Line 45: The decorator accepts an optional "update" callable, called each
time the
Line 46: memoized function is called. If update() return True, the memoized cache is
update() return True -> update() returns True
Done
Line 47: invalidated. If the update is not set, the cache is never invalidated.
Line 48:
Line 49: The memoized function may accept multiple positional arguments. The
Line 50: cache store the result for each combination of arguments. Functions with
Line 46: memoized function is called. If update() return True, the memoized cache is
Line 47: invalidated. If the update is not set, the cache is never invalidated.
Line 48:
Line 49: The memoized function may accept multiple positional arguments. The
Line 50: cache store the result for each combination of arguments. Functions with
store->stores
Done
Line 51: kwargs are not supported.
Line 52:
Line 53: Memoized functions have an "invalidate" method, used to invalidate
the
Line 54: cache externally. This is required for testing memoized functions.
Line 100: stats = os.stat(self.path)
Line 101: except OSError as e:
Line 102: if e.errno != errno.ENOENT:
Line 103: raise
Line 104: stats = None
I don't think so. file_modified should invalidate the cache when
a file was
Agreed, the current implementation also considers file creation and
removal as update events, which sounds like a proper behavior.
Line 105: else:
Line 106: stats = stats.st_ino, stats.st_size, stats.st_mtime
Line 107: if stats != self.stats:
Line 108: self.stats = stats
--
To view, visit
http://gerrit.ovirt.org/34709
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I6dd8fb29d94286e3e3a3e29b8218501cbdc5c018
Gerrit-PatchSet: 4
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: Adam Litke <alitke(a)redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Martin Sivák <msivak(a)redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi(a)redhat.com>
Gerrit-Reviewer: Vitor de Lima <vdelima(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes