T
- public class ERXEnterpriseObjectArrayCache<T extends EOEnterpriseObject> extends Object
ERXEnterpriseObjectArrayCache<HelpText> helpTextCache = new ERXEnterpriseObjectArrayCache<HelpText>("HelpText") {
protected void handleUnsuccessfullQueryForKey(Object key) {
NSArray helpTexts = ... fetch from somewhere
setObjectsForKey(helpTexts, key);
}
};
...
NSArray<HelpText> helpTexts = helpTextCache.objectsForKey(ec, "AllTexts");
...
You can supply a timeout after which the cache is to get cleared and all the objects refetched. Note
that this implementation only caches the global IDs, not the actual data.Modifier and Type | Class and Description |
---|---|
static class |
ERXEnterpriseObjectArrayCache.NotFoundArray |
Modifier and Type | Field and Description |
---|---|
protected static NSArray |
NOT_FOUND_MARKER |
Constructor and Description |
---|
ERXEnterpriseObjectArrayCache(Class c)
Creates the cache for the given entity name and the given keypath.
|
ERXEnterpriseObjectArrayCache(String entityName)
Creates the cache for the given entity name and the given keypath.
|
ERXEnterpriseObjectArrayCache(String entityName,
long timeout)
Creates the cache for the given entity, keypath and timeout value in milliseconds.
|
Modifier and Type | Method and Description |
---|---|
protected NSArray<EOGlobalID> |
cachedArrayForKey(Object key) |
void |
clearCaches(NSNotification n)
Handler for the clearCaches notification.
|
void |
editingContextDidSaveChanges(NSNotification n)
Handler for the editingContextDidSaveChanges notification.
|
protected String |
entityName() |
protected static String |
entityNameForClass(Class c) |
protected long |
fetchTime() |
protected void |
handleUnsuccessfullQueryForKey(Object key)
Called when a query hasn't found an entry in the cache.
|
protected boolean |
isNotFound(NSArray<EOGlobalID> gids) |
NSArray<T> |
objectsForKey(EOEditingContext ec,
Object key)
Retrieves a list of EOs that matches the given key or null if no match
is in the cache.
|
protected void |
registerForNotifications() |
void |
reset()
Resets the cache by clearing the internal map.
|
protected void |
setCachedArrayForKey(NSArray<EOGlobalID> gids,
Object key) |
void |
setObjectsForKey(NSArray<? extends EOEnterpriseObject> bugs,
Object key)
Add a list of objects to the cache with the given key.
|
protected long |
timeout() |
protected static final NSArray NOT_FOUND_MARKER
public ERXEnterpriseObjectArrayCache(String entityName)
entityName
- public ERXEnterpriseObjectArrayCache(Class c)
public ERXEnterpriseObjectArrayCache(String entityName, long timeout)
entityName
- timeout
- protected void registerForNotifications()
public void editingContextDidSaveChanges(NSNotification n)
n
- public void clearCaches(NSNotification n)
n
- protected String entityName()
public void setObjectsForKey(NSArray<? extends EOEnterpriseObject> bugs, Object key)
bugs
- array of objectsprotected void setCachedArrayForKey(NSArray<EOGlobalID> gids, Object key)
protected NSArray<EOGlobalID> cachedArrayForKey(Object key)
public NSArray<T> objectsForKey(EOEditingContext ec, Object key)
ec
- editing context to get the objects intokey
- key value under which the objects are registeredprotected boolean isNotFound(NSArray<EOGlobalID> gids)
protected void handleUnsuccessfullQueryForKey(Object key)
setObjectsForKey(NSArray, Object)
on it.key
- public void reset()
protected long timeout()
protected long fetchTime()
Copyright © 2002 – 2024 Project Wonder.