S - This typeK - The location key typepublic abstract class SaveSection<S extends SaveSection<S,K>,K extends IKey<K>>
extends java.lang.Object
implements java.io.Flushable, java.io.Closeable
| Constructor and Description |
|---|
SaveSection(IRegionProvider<K> regionProvider)
Creates a SaveSection with a customized IRegionProvider
|
SaveSection(java.util.List<IRegionProvider<K>> regionProviders)
Creates a SaveSection with a customized IRegionProviders, with each next RegionProvider used as a fallback
in case reading/writing is unsuccessful
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
void |
forAllKeys(CheckedConsumer<? super K,java.io.IOException> cons)
Applies the given consumer to all already saved keys.
|
boolean |
hasEntry(K key) |
java.util.Optional<java.nio.ByteBuffer> |
load(K key,
boolean createRegion)
Loads/gets a value at a key
This Method is thread safe.
|
void |
save(K key,
java.nio.ByteBuffer value)
Saves/puts a value at a key
This method is thread safe.
|
public SaveSection(IRegionProvider<K> regionProvider)
regionProvider - The region providerpublic SaveSection(java.util.List<IRegionProvider<K>> regionProviders)
regionProviders - The region providerspublic void save(K key, java.nio.ByteBuffer value) throws java.io.IOException
key - The keyvalue - The value to savejava.io.IOException - when an unexpected IO error occurspublic java.util.Optional<java.nio.ByteBuffer> load(K key, boolean createRegion) throws java.io.IOException
key - The keycreateRegion - if true, a new region file will be created and cached. This is the preferred option.java.io.IOException - when an unexpected IO error occurspublic void forAllKeys(CheckedConsumer<? super K,java.io.IOException> cons) throws java.io.IOException
cons - Consumer that will accept all the existing regionsjava.io.IOException - when an unexpected IO error occurspublic boolean hasEntry(K key) throws java.io.IOException
java.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