Class BOCache<T>
java.lang.Object
overit.geocallapp.utilities.core.cache.BOCache<T>
- Type Parameters:
T- the type of business objects stored in this cache
- All Implemented Interfaces:
Serializable
Generic cache implementation for business objects with lazy loading capabilities.
This class provides a thread-safe caching mechanism for business objects that are loaded on-demand using
Key features:
This class provides a thread-safe caching mechanism for business objects that are loaded on-demand using
LoadEvent instances. The cache automatically loads
objects when they are first requested and stores them for subsequent access. Key features:
- Since:
- 1.0
- See Also:
- GCApi:
- bo
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves an object from the cache with automaticPoolKitmanagement.Retrieves an object from the cache, loading it if not present.Returns all cached objects as a collection.static <T> BOCache<T> makeBOCache(Class<? extends LoadEvent<T>> loadEventClass) Factory method to create a new cache instance with the specifiedLoadEventclass.static <T> BOCache<T> makeBOCache(Class<? extends LoadEvent<T>> loadEventClass, EventOptions eventOptions) Factory method to create a new cache instance with the specifiedLoadEventclass.protected voidsetEventOptions(EventOptions eventOptions) protected voidsetLoadEventClass(Class<? extends LoadEvent<T>> loadEventClass) Sets theLoadEventclass used for loading objects into the cache.
-
Field Details
-
LOG
-
-
Constructor Details
-
BOCache
public BOCache()
-
-
Method Details
-
makeBOCache
Factory method to create a new cache instance with the specifiedLoadEventclass. -
makeBOCache
public static <T> BOCache<T> makeBOCache(Class<? extends LoadEvent<T>> loadEventClass, EventOptions eventOptions) Factory method to create a new cache instance with the specifiedLoadEventclass.- Type Parameters:
T- the type of objects to be cached- Parameters:
loadEventClass- theLoadEventclass used to load objects into the cacheeventOptions- theEventOptionsto configure the event behavior- Returns:
- a new cache instance configured with the specified
LoadEventclass
-
setLoadEventClass
Sets theLoadEventclass used for loading objects into the cache.- Parameters:
loadEventClass- theLoadEventclass to use for object loading
-
setEventOptions
-
get
Retrieves an object from the cache, loading it if not present. This method provides thread-safe access to cached objects. If the requested object is not in the cache, it automatically creates aLoadEventinstance using reflection, executes it with the providedPoolKit, and stores the result in the cache.- Parameters:
key- the unique identifier for the object to retrievepoolKit- thePoolKitfor database operations- Returns:
- the cached or newly loaded object, or null if loading fails
-
get
Retrieves an object from the cache with automaticPoolKitmanagement.- Parameters:
key- the unique identifier for the object to retrieve- Returns:
- the cached or newly loaded object, or null if loading fails or database errors occur
-
getValues
Returns all cached objects as a collection. This method provides access to all objects currently stored in the cache. The returned collection is a view of the cache values, so modifications to the cache will be reflected in the collection. Note that this method only returns objects that have already been loaded into the cache. It does not trigger loading of any additional objects.- Returns:
- a collection containing all cached objects
-