use of com.apple.foundationdb.record.provider.foundationdb.keyspace.ScopedValue in project fdb-record-layer by FoundationDB.
the class FDBReverseDirectoryCache method put.
/**
* Explicitly add a new entry to the reverse directory cache.
*
* @param context the transactional context
* @param pathKey the name of an entry in the FDB directory, the value of which is retrieved from the directory
* and explicitly inserted into the reverse directory cache
* @return a future that performs the action
* @throws NoSuchElementException will be thrown by this future if the <code>name</code> provided does not exist in the directory layer.
*/
public CompletableFuture<Void> put(@Nonnull FDBRecordContext context, @Nonnull ScopedValue<String> pathKey) {
final LocatableResolver scope = pathKey.getScope();
final String key = pathKey.getData();
return getReverseCacheSubspace(scope).thenCompose(reverseCacheSubspace -> scope.mustResolve(context, key).thenApply(value -> {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(KeyValueLogMessage.of("Adding value to reverse directory cache", LogMessageKeys.KEY, pathKey, LogMessageKeys.VALUE, value));
}
context.ensureActive().set(reverseCacheSubspace.pack(value), Tuple.from(pathKey.getData()).pack());
return null;
}));
}
Aggregations