Interface MetaDataCache
-
@API(EXPERIMENTAL) public interface MetaDataCache
A caching hook forFDBMetaDataStore
. A cache implementation can implement any subset of object, serialized and version cached. The caller is responsible for calling all of the relevant theset
methods when something changes.Note that this interface is currently undergoing active development. Work on evolving this API is currently being tracked as part of Issue #280. Users are advised to avoid implementing or using this interface until work on that issue has been completed.
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default RecordMetaData
getCachedMetaData()
Get cachedRecordMetaData
object.default byte[]
getCachedSerialized()
Get cached serialized meta-data.default CompletableFuture<Integer>
getCurrentVersionAsync(FDBRecordContext context)
Get a version to use for cache validation of-1
to skip validation.default void
setCachedMetaData(RecordMetaData metaData)
Cache meta-data object.default void
setCachedSerialized(byte[] serialized)
Cache serialized meta-data.default void
setCurrentVersion(FDBRecordContext context, int version)
Update the version used for cache validation.
-
-
-
Method Detail
-
getCurrentVersionAsync
default CompletableFuture<Integer> getCurrentVersionAsync(FDBRecordContext context)
Get a version to use for cache validation of-1
to skip validation.- Parameters:
context
- the transaction to use to access the database- Returns:
- a future that completes with the current version
-
getCachedMetaData
@Nullable default RecordMetaData getCachedMetaData()
Get cachedRecordMetaData
object. For instance, from a Guava cache.- Returns:
- any cached meta-data
-
getCachedSerialized
@Nullable default byte[] getCachedSerialized()
Get cached serialized meta-data. For instance, from Memcache.- Returns:
- any cached serialized form
-
setCurrentVersion
default void setCurrentVersion(FDBRecordContext context, int version)
Update the version used for cache validation.If maintained, the version should be stored in a way that is transactionally consistent with the given
context
. For instance, in one or more key-value pairs.- Parameters:
context
- the transaction to use to access the databaseversion
- the new current version- See Also:
getCurrentVersionAsync(FDBRecordContext)
-
setCachedMetaData
default void setCachedMetaData(@Nonnull RecordMetaData metaData)
Cache meta-data object.This cache can be kept in memory. If
setCurrentVersion(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext, int)
is supported, it is still possible to determine when it is out-of-date, even if changed by some other client.- Parameters:
metaData
- the new cached meta-data- See Also:
getCachedMetaData()
-
setCachedSerialized
default void setCachedSerialized(@Nonnull byte[] serialized)
Cache serialized meta-data.This cache is normally maintained some place that is not transationally consistent. In which case, if multiple clients can change the meta-data,
setCurrentVersion(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext, int)
should also be supported.- Parameters:
serialized
- the new cached serialized meta-data- See Also:
getCachedSerialized()
-
-