public final class FilePerKeyValueStore extends net.openhft.chronicle.core.io.SimpleCloseable implements StringBytesStoreKeyValueStore
Map
implementation that stores each entry as a file in a directory. The
key
is the file fullName and the value
is the contents of the file. The class is effectively an abstraction over a directory in the file system. Therefore when the underlying files are changed an event will be fired to those registered for notifications.
Updates will be fired every time the file is saved but will be suppressed if the value has not changed. To avoid temporary files (e.g. if edited in vi) being included in the map, any file starting with a '.' will be ignored.
Note the WatchService
is extremely OS dependant.
Mas OSX registers very few events if they are done quickly and there is a significant delay
between the event and the event being triggered.
KeyValueStore.Entry<K,V>
Constructor and Description |
---|
FilePerKeyValueStore(@NotNull RequestContext context,
@NotNull Asset asset) |
Modifier and Type | Method and Description |
---|---|
@NotNull Asset |
asset() |
void |
clear() |
boolean |
containsValue(net.openhft.chronicle.bytes.BytesStore value) |
void |
entriesFor(int segment,
@NotNull SubscriptionConsumer<MapEvent<String,net.openhft.chronicle.bytes.BytesStore>> kvConsumer) |
Iterator<Map.Entry<String,net.openhft.chronicle.bytes.BytesStore>> |
entrySetIterator() |
@Nullable net.openhft.chronicle.bytes.BytesStore |
getAndPut(String key,
@NotNull net.openhft.chronicle.bytes.BytesStore value) |
@Nullable net.openhft.chronicle.bytes.BytesStore |
getAndRemove(String key) |
@Nullable net.openhft.chronicle.bytes.BytesStore |
getUsing(String key,
Object value) |
Iterator<String> |
keySetIterator() |
void |
keysFor(int segment,
@NotNull SubscriptionConsumer<String> stringConsumer) |
long |
longSize() |
protected void |
performClose() |
boolean |
put(String key,
@NotNull net.openhft.chronicle.bytes.BytesStore value)
put an entry
|
boolean |
remove(String key)
remove a key
|
@NotNull RawKVSSubscription<String,net.openhft.chronicle.bytes.BytesStore> |
subscription(boolean createIfAbsent) |
@Nullable KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore> |
underlying() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
containsKey, get, isKeyType, isReadOnly, putIfAbsent, removeIfEqual, replace, replaceIfEqual, segmentFor, segments, valuesIterator
close, closeQuietly, closeQuietly
public FilePerKeyValueStore(@NotNull @NotNull RequestContext context, @NotNull @NotNull Asset asset)
@NotNull public @NotNull RawKVSSubscription<String,net.openhft.chronicle.bytes.BytesStore> subscription(boolean createIfAbsent)
subscription
in interface SubscriptionKeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>
public long longSize()
longSize
in interface KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>
@Nullable public @Nullable net.openhft.chronicle.bytes.BytesStore getUsing(String key, Object value)
getUsing
in interface KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>
public void keysFor(int segment, @NotNull @NotNull SubscriptionConsumer<String> stringConsumer)
keysFor
in interface KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>
public void entriesFor(int segment, @NotNull @NotNull SubscriptionConsumer<MapEvent<String,net.openhft.chronicle.bytes.BytesStore>> kvConsumer)
entriesFor
in interface KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>
public Iterator<String> keySetIterator()
keySetIterator
in interface KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>
public Iterator<Map.Entry<String,net.openhft.chronicle.bytes.BytesStore>> entrySetIterator()
entrySetIterator
in interface KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>
public boolean put(String key, @NotNull @NotNull net.openhft.chronicle.bytes.BytesStore value)
KeyValueStore
put
in interface KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>
key
- to setvalue
- to set@Nullable public @Nullable net.openhft.chronicle.bytes.BytesStore getAndPut(String key, @NotNull @NotNull net.openhft.chronicle.bytes.BytesStore value)
getAndPut
in interface KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>
@Nullable public @Nullable net.openhft.chronicle.bytes.BytesStore getAndRemove(String key)
getAndRemove
in interface KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>
public boolean remove(String key)
KeyValueStore
remove
in interface KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>
key
- to removepublic void clear()
clear
in interface KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>
public boolean containsValue(net.openhft.chronicle.bytes.BytesStore value)
containsValue
in interface KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>
protected void performClose()
performClose
in class net.openhft.chronicle.core.io.SimpleCloseable
@NotNull public @NotNull Asset asset()
asset
in interface Assetted<KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>>
@Nullable public @Nullable KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore> underlying()
underlying
in interface Assetted<KeyValueStore<String,net.openhft.chronicle.bytes.BytesStore>>
Copyright © 2021. All rights reserved.