-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure index usage is in sync and try to improve inventory updates
Signed-off-by: Alexis Jeandet <[email protected]>
- Loading branch information
Showing
4 changed files
with
40 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
from ..config import index as index_cfg | ||
from diskcache import Index | ||
|
||
index = Index(index_cfg.path()) | ||
_index = Index(index_cfg.path()) | ||
|
||
|
||
class IndexEntry: | ||
def __init__(self, key: str, default=None): | ||
self._key = key | ||
with _index.transact(): | ||
_index[self._key] = default | ||
|
||
def value(self): | ||
with _index.transact(): | ||
return _index[self._key] | ||
|
||
def set(self, value): | ||
with _index.transact(): | ||
_index[self._key] = value | ||
|
||
|
||
up_since = IndexEntry("up_since", None) |