-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure only a single object instance exists per tree object (#415)
Ensure only a single instance refers to the same tree object or container. Add a mixin class `ObjectCacheMixin` which adds a class attribute `_OBJECT_CACHE` to each of its subclasses. The object cache is a `WeakValueDictionary`, meaning the instances will be properly deleted once their refcount _outside_ of the object cache goes to zero. The `ObjectCacheMixin` subclasses need to provide a method `_cache_key_valid`; this enables making certain cache key values disallowed. In particular, empty resource paths are not considered valid for tree objects. A decorator `constructor_with_cache` is provided to decorate constructor classmethods s.t. they use the cache. The arguments to the `__init__` method in the container classes `Mapping`, `MutableMapping`, `LinkedObjectList` and `EdgePropertyList` are prefixed with underscores, to prevent accidental use of the direct constructor. Tree objects which are directly instantiated are added to the cache during `.store()`.
- Loading branch information
Showing
8 changed files
with
508 additions
and
53 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
Oops, something went wrong.