cache_factory module¶
This module contains a factory to instantiate a AbstractCache
from its
class name.
The class can be internal to GEMSEO or located in an external module whose path is provided to the constructor. It also provides a list of available cache types and allows you to test if a cache type is available.
Classes:
This factory instantiates a |
- class gemseo.caches.cache_factory.CacheFactory[source]¶
Bases:
object
This factory instantiates a
AbstractCache
from its class name.The class can be internal to GEMSEO or located in an external module whose path is provided to the constructor.
Initializes the factory: scans the directories to search for subclasses of AbstractCache.
Searches in “GEMSEO” and gemseo.caches
Attributes:
Lists the available classes.
Methods:
create
(cache_name, **options)Create a cache.
is_available
(cache_name)Checks the availability of a cache.
- property caches¶
Lists the available classes.
- Returns
the list of classes names.
- Return type
list(str)
Examples
>>> from gemseo.caches.cache_factory import CacheFactory >>> CacheFactory().caches ['AbstractFullCache', 'HDF5Cache', 'MemoryFullCache', 'SimpleCache']
- create(cache_name, **options)[source]¶
Create a cache.
- Parameters
cache_name (str) – name of the cache (its classname)
options – additional options specific
- Returns
cache_name cache
Examples
>>> from gemseo.caches.cache_factory import CacheFactory >>> cache = CacheFactory().create('MemoryFullCache', name='my_cache') my_cache |_ Type: MemoryFullCache |_ Input names: None |_ Output names: None |_ Length: 0 |_ Tolerance: 0.0
- is_available(cache_name)[source]¶
Checks the availability of a cache.
- Parameters
cache_name (str) – cache_name of the cache.
- Returns
True if the cache is available.
- Return type
bool
Examples
>>> from gemseo.caches.cache_factory import CacheFactory >>> CacheFactory().is_available('SimpleCache') True >>> CacheFactory().is_available('UnavailableCache') False