public class SharedCachedRegionProvider<K extends IKey<K>> extends java.lang.Object implements IRegionProvider<K>
| Constructor and Description |
|---|
SharedCachedRegionProvider(IRegionFactory<K> regionFactory)
Creates a RegionProvider using the given
regionFactory |
SharedCachedRegionProvider(IRegionFactory<K> regionFactory,
SharedCache cache)
Creates a RegionProvider using the given
regionFactory and cache |
| Modifier and Type | Method and Description |
|---|---|
java.util.stream.Stream<java.util.Map.Entry<K,java.nio.ByteBuffer>> |
allEntries()
Gets a
Stream over all already saved entries. |
java.util.stream.Stream<K> |
allKeys()
Gets a
Stream over all already saved keys. |
java.util.stream.Stream<RegionKey> |
allRegions()
Gets a
Stream over the keys of all the existing regions. |
void |
close() |
void |
flush() |
void |
forExistingRegion(K key,
CheckedConsumer<? super IRegion<K>,java.io.IOException> cons)
Calls the given function with region at that location and returns value from that function..
|
void |
forRegion(K key,
CheckedConsumer<? super IRegion<K>,java.io.IOException> cons)
Calls the given consumer with region at that location.
|
<R> java.util.Optional<R> |
fromExistingRegion(K key,
CheckedFunction<? super IRegion<K>,R,java.io.IOException> func)
Calls the given consumer with region at that location.
|
<R> R |
fromRegion(K key,
CheckedFunction<? super IRegion<K>,R,java.io.IOException> func)
Calls the given function with region at that location and returns value from that function.
|
public SharedCachedRegionProvider(IRegionFactory<K> regionFactory)
regionFactoryregionFactory - IRegionFactory used as source of regionspublic SharedCachedRegionProvider(IRegionFactory<K> regionFactory, SharedCache cache)
regionFactory and cacheregionFactory - IRegionFactory used as source of regionspublic <R> java.util.Optional<R> fromExistingRegion(K key, CheckedFunction<? super IRegion<K>,R,java.io.IOException> func) throws java.io.IOException
IRegionProviderfromExistingRegion in interface IRegionProvider<K extends IKey<K>>key - The key for the IRegionregionKey if it existsjava.io.IOExceptionpublic <R> R fromRegion(K key, CheckedFunction<? super IRegion<K>,R,java.io.IOException> func) throws java.io.IOException
IRegionProviderfromRegion in interface IRegionProvider<K extends IKey<K>>key - The key for the IRegionjava.io.IOExceptionpublic void forRegion(K key, CheckedConsumer<? super IRegion<K>,java.io.IOException> cons) throws java.io.IOException
IRegionProviderforRegion in interface IRegionProvider<K extends IKey<K>>key - The key for the IRegioncons - Consumer that accepts the IRegionjava.io.IOExceptionpublic void forExistingRegion(K key, CheckedConsumer<? super IRegion<K>,java.io.IOException> cons) throws java.io.IOException
IRegionProviderforExistingRegion in interface IRegionProvider<K extends IKey<K>>key - The key for the IRegioncons - Accepts the given region, if it already existsjava.io.IOExceptionpublic java.util.stream.Stream<RegionKey> allRegions() throws java.io.IOException
IRegionProviderStream over the keys of all the existing regions.
All regions that had been created at the time of this method invocation are guaranteed to be present in the returned Stream, no guarantees
are made for regions created during iteration.
The returned Stream should be closed (using BaseStream.close()) once no longer needed to avoid potential
resource leaks. If not closed, any resources allocated by the Stream may not be freed until the Stream
instance is garbage-collected.
allRegions in interface IRegionProvider<K extends IKey<K>>Stream over the keys of all the existing regionsjava.io.IOExceptionpublic java.util.stream.Stream<K> allKeys() throws java.io.IOException
IRegionProviderStream over all already saved keys.
Keys saved while the Stream is being evaluated are not guaranteed to be listed.
The returned Stream should be closed (using BaseStream.close()) once no longer needed to avoid potential
resource leaks. If not closed, any resources allocated by the Stream may not be freed until the Stream
instance is garbage-collected.
allKeys in interface IRegionProvider<K extends IKey<K>>Stream over all already saved keysjava.io.IOExceptionpublic java.util.stream.Stream<java.util.Map.Entry<K,java.nio.ByteBuffer>> allEntries() throws java.io.IOException
IRegionProviderStream over all already saved entries.
Entries saved while the Stream is being evaluated are not guaranteed to be listed.
The returned Stream should be closed (using BaseStream.close()) once no longer needed to avoid potential
resource leaks. If not closed, any resources allocated by the Stream may not be freed until the Stream
instance is garbage-collected.
allEntries in interface IRegionProvider<K extends IKey<K>>Stream over all already saved entriesjava.io.IOExceptionpublic void flush()
throws java.io.IOException
flush in interface java.io.Flushablejava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException