Class ReadVersionRecordStoreStateCache

  • All Implemented Interfaces:
    FDBRecordStoreStateCache

    @API(EXPERIMENTAL)
    public class ReadVersionRecordStoreStateCache
    extends Object
    implements FDBRecordStoreStateCache
    An implementation of the FDBRecordStoreStateCache that uses the read-version of the associated transaction as the cache invalidation key. In general, it is not particularly likely that multiple transactions started against the same database will share the same read version, so without any other work, this cache should be expected to have a rather low hit-rate. However, when combined with version-caching and setting the weak read semantics of a context to use cached read versions, one can greatly increase the cache hit rate. This means that in cases where stale reads are acceptable and many transactions share the same read version, opening the same record store multiple times with the same read version (even if the transactions are different) can be made very cheap.
    See Also:
    FDBDatabase.setTrackLastSeenVersion(boolean), FDBDatabase.WeakReadSemantics
    • Method Detail

      • get

        @Nonnull
        public CompletableFuture<FDBRecordStoreStateCacheEntry> get​(@Nonnull
                                                                    FDBRecordStore recordStore,
                                                                    @Nonnull
                                                                    FDBRecordStoreBase.StoreExistenceCheck existenceCheck)
        Description copied from interface: FDBRecordStoreStateCache
        Load the record store state for the record store stored at the given location. If this information is available in the cache, it will be served from memory without communicating with the database. Otherwise, the information may require performing network and disk I/O. Note that the cache entry returned should be consistent with the view of the database as viewed by the transaction provided as input. The cache implementations are generally differentiated by the manner in which they invalidate data to ensure that the value returned is consistent with this contract.

        This method should generally not be called by clients importing the Record Layer.

        Specified by:
        get in interface FDBRecordStoreStateCache
        Parameters:
        recordStore - the record store to load the store state of
        existenceCheck - whether to error if the store does or does not exist
        Returns:
        a future that will complete with the cached store state