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.
-
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_PATH” and gemseo.caches
-
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
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
-
property