V - The object it is cachingpublic class Cache<V> extends Object
An internal cached element
An internal cached object which hits the database only when it needs to.
This is used to cache the components of ontological concepts. i.e. the fields of Type,
RelationshipType, and Role.
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears the cache.
|
static Cache |
createPersistentCache(CacheOwner owner,
Cacheable cacheable,
java.util.function.Supplier databaseReader)
Creates a session level
Cache which cannot be cleared. |
static Cache |
createSessionCache(CacheOwner owner,
Cacheable cacheable,
java.util.function.Supplier databaseReader)
Creates a
Cache that will only flush to a central shared cache then the Transaction is disposed off |
static Cache |
createTxCache(CacheOwner owner,
Cacheable cacheable,
java.util.function.Supplier databaseReader)
Creates a
Cache that will only exist within the context of a Transaction |
void |
flush()
Takes the current value in the transaction cache if it is present and puts it in the valueGlobal reference so
that it can be accessed via all transactions.
|
V |
get()
Retrieves the object in the cache.
|
void |
ifPresent(java.util.function.Consumer<V> modifier)
Mutates the cached value if something is cached.
|
boolean |
isPresent() |
void |
set(V value)
Explicitly set the cache to a provided value
|
public static Cache createTxCache(CacheOwner owner, Cacheable cacheable, java.util.function.Supplier databaseReader)
Cache that will only exist within the context of a Transactionpublic static Cache createSessionCache(CacheOwner owner, Cacheable cacheable, java.util.function.Supplier databaseReader)
Cache that will only flush to a central shared cache then the Transaction is disposed offpublic static Cache createPersistentCache(CacheOwner owner, Cacheable cacheable, java.util.function.Supplier databaseReader)
Cache which cannot be cleared.
When creating these types of Caches the only way to get rid of them is to remove the owner ConceptImpl@Nullable public V get()
public void clear()
public void set(@Nullable V value)
value - the value to be cachedpublic boolean isPresent()
public void ifPresent(java.util.function.Consumer<V> modifier)
modifier - the mutator function.public void flush()
Copyright © 2018 Grakn Labs Ltd. All rights reserved.