public class DatabaseCacheImpl extends Object implements DatabaseCache
DatabaseCache
. There are actually three
separate caches:
Modifier and Type | Class and Description |
---|---|
protected class |
DatabaseCacheImpl.ChronicleCache
ChronicleCache is an LRU cache which requests removal of the least
recently accessed value when the capacity is exceeded.
|
Constructor and Description |
---|
DatabaseCacheImpl(Database db,
int capacity)
Construct a
DatabaseCache with a 0.75 load factor. |
DatabaseCacheImpl(Database db,
int capacity,
float loadFactor)
Construct a
DatabaseCache . |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the cache.
|
void |
clear(Chronicle chronicle)
Remove a chronicle from the cache if present.
|
void |
clear(Property<?> property)
Remove a property from the cache if present.
|
void |
clear(Schema schema)
Remove a schema from the cache if present.
|
void |
clear(ValueType<?> valueType)
Remove a value type from the cache if present.
|
ChronicleImpl |
lookUpChronicle(String name)
Look up a chronicle in the cache by name.
|
ChronicleImpl |
lookUpChronicle(Surrogate surrogate)
Look up a chronicle in the cache.
|
Property<?> |
lookUpProperty(String name)
Look up a property in the cache by name.
|
void |
setMessageListener(MessageListener messageListener)
Set a message listener.
|
int |
size()
Return the number of chronicles currently in the cache.
|
ChronicleImpl |
store(ChronicleImpl entity)
Store a chronicle in the cache and return a copy.
|
public DatabaseCacheImpl(Database db, int capacity, float loadFactor)
DatabaseCache
.db
- the database being cachedcapacity
- a positive numberloadFactor
- a number between 0 and 1public DatabaseCacheImpl(Database db, int capacity)
DatabaseCache
with a 0.75 load factor.db
- the database being cachedcapacity
- a positive numberpublic void setMessageListener(MessageListener messageListener)
messageListener
- a message listenerpublic ChronicleImpl lookUpChronicle(Surrogate surrogate)
DatabaseCache
lookUpChronicle
in interface DatabaseCache
surrogate
- a chronicle surrogatepublic ChronicleImpl lookUpChronicle(String name)
DatabaseCache
lookUpChronicle
in interface DatabaseCache
name
- a stringpublic Property<?> lookUpProperty(String name) throws T2DBException
DatabaseCache
lookUpProperty
in interface DatabaseCache
name
- a stringT2DBException
public ChronicleImpl store(ChronicleImpl entity) throws T2DBException
DatabaseCache
store
in interface DatabaseCache
entity
- a chronicleT2DBException
public int size()
DatabaseCache
size
in interface DatabaseCache
public void clear()
DatabaseCache
clear
in interface DatabaseCache
public void clear(Chronicle chronicle)
DatabaseCache
clear
in interface DatabaseCache
chronicle
- a chroniclepublic void clear(Schema schema)
DatabaseCache
clear
in interface DatabaseCache
schema
- a schemapublic void clear(Property<?> property)
DatabaseCache
clear
in interface DatabaseCache
property
- a propertypublic void clear(ValueType<?> valueType)
DatabaseCache
clear
in interface DatabaseCache
valueType
- a valueTypeCopyright © 2017. All rights reserved.