Interface ORecordCache
- All Known Implementing Classes:
OAbstractMapCache,ORecordCacheSoftRefs,ORecordCacheWeakRefs
public interface ORecordCache
Generic cache interface that should be implemented in order to plug-in custom cache. Also
implementing class has to have public one-arg constructor to set cache limit. For example, next
class can be safely used as plug-in cache:
public class CustomCache implements OCache {
public CustomCache(int initialLimit) {
// some actions to do basic initialization of cache instance
...
}
//implementation of interface
...
}
As reference implementation used ORecordCacheWeakRefs- Author:
- Maxim Fedorov
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Remove all records from cachevoidbooleandisable()Disable cache.booleanenable()Enable cacheLook up for record in cache by it's identifierbooleanTell whether cache is enabledkeys()Keys of all stored in cache recordsPush record to cache.Remove record with specified identifiervoidshutdown()All operations running at cache destruction stageintsize()Total number of stored recordsvoidstartup()All operations running at cache initialization stage
-
Method Details
-
startup
void startup()All operations running at cache initialization stage -
shutdown
void shutdown()All operations running at cache destruction stage -
isEnabled
boolean isEnabled()Tell whether cache is enabled- Returns:
trueif cache enabled at call time, otherwise -false
-
enable
boolean enable()Enable cache- Returns:
true- if enabled,false- otherwise (already enabled)
-
disable
boolean disable()Disable cache. None of record management methods will cause effect on cache in disabled state. Only cache info methods available at that state.- Returns:
true- if disabled,false- otherwise (already disabled)
-
get
Look up for record in cache by it's identifier- Parameters:
id- unique identifier of record- Returns:
- record stored in cache if any, otherwise -
null
-
put
Push record to cache. Identifier of record used as access key- Parameters:
record- record that should be cached- Returns:
- previous version of record
-
remove
Remove record with specified identifier- Parameters:
id- unique identifier of record- Returns:
- record stored in cache if any, otherwise -
null
-
clear
void clear()Remove all records from cache -
size
int size()Total number of stored records- Returns:
- non-negative number
-
keys
Collection<ORID> keys()Keys of all stored in cache records- Returns:
- keys of records
-
clearRecords
void clearRecords()
-