public class FilePerKeyValueStore extends Object implements StringBytesStoreKeyValueStore, Closeable
Map implementation that stores each entry as a file in a
directory. The key is the file name 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(FactoryContext context) |
| Modifier and Type | Method and Description |
|---|---|
Asset |
asset() |
void |
asset(Asset asset) |
void |
clear() |
void |
close() |
void |
entriesFor(int segment,
java.util.function.Consumer<KeyValueStore.Entry<String,net.openhft.chronicle.bytes.BytesStore>> kvConsumer) |
Iterator<Map.Entry<String,net.openhft.chronicle.bytes.BytesStore>> |
entrySetIterator() |
View |
forSession(LocalSession session,
Asset asset) |
net.openhft.chronicle.bytes.BytesStore |
getAndPut(String key,
net.openhft.chronicle.bytes.BytesStore value) |
net.openhft.chronicle.bytes.BytesStore |
getAndRemove(String key) |
net.openhft.chronicle.bytes.BytesStore |
getUsing(String key,
net.openhft.chronicle.bytes.Bytes value) |
void |
keysFor(int segment,
java.util.function.Consumer<String> stringConsumer) |
void |
put(String key,
net.openhft.chronicle.bytes.BytesStore value) |
<E> void |
registerSubscriber(Class<E> eClass,
Subscriber<E> subscriber,
String query) |
<T,E> void |
registerTopicSubscriber(Class<T> tClass,
Class<E> eClass,
TopicSubscriber<T,E> subscriber,
String query) |
void |
remove(String key) |
long |
size() |
KeyValueStore |
underlying() |
void |
underlying(KeyValueStore underlying) |
<E> void |
unregisterSubscriber(Class<E> eClass,
Subscriber<E> subscriber,
String query) |
<T,E> void |
unregisterTopicSubscriber(Class<T> tClass,
Class<E> eClass,
TopicSubscriber<T,E> subscriber,
String query) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcontainsKey, get, isReadOnly, replace, segmentFor, segmentsisUnderlyingforSessionpublic FilePerKeyValueStore(FactoryContext context) throws net.openhft.chronicle.bytes.IORuntimeException
net.openhft.chronicle.bytes.IORuntimeExceptionpublic View forSession(LocalSession session, Asset asset)
forSession in interface Viewpublic long size()
size in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public net.openhft.chronicle.bytes.BytesStore getUsing(String key, net.openhft.chronicle.bytes.Bytes value)
getUsing in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public void keysFor(int segment,
java.util.function.Consumer<String> stringConsumer)
keysFor in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public void entriesFor(int segment,
java.util.function.Consumer<KeyValueStore.Entry<String,net.openhft.chronicle.bytes.BytesStore>> kvConsumer)
entriesFor in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,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.Bytes,net.openhft.chronicle.bytes.BytesStore>public void put(String key, net.openhft.chronicle.bytes.BytesStore value)
put in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public net.openhft.chronicle.bytes.BytesStore getAndPut(String key, net.openhft.chronicle.bytes.BytesStore value)
getAndPut in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public net.openhft.chronicle.bytes.BytesStore getAndRemove(String key)
getAndRemove in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public void remove(String key)
remove in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public void clear()
clear in interface KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>public void close()
close in interface Closeableclose in interface AutoCloseablepublic <E> void registerSubscriber(Class<E> eClass, Subscriber<E> subscriber, String query)
registerSubscriber in interface Subscriptionpublic <T,E> void registerTopicSubscriber(Class<T> tClass, Class<E> eClass, TopicSubscriber<T,E> subscriber, String query)
registerTopicSubscriber in interface Subscriptionpublic <E> void unregisterSubscriber(Class<E> eClass, Subscriber<E> subscriber, String query)
unregisterSubscriber in interface Subscriptionpublic <T,E> void unregisterTopicSubscriber(Class<T> tClass, Class<E> eClass, TopicSubscriber<T,E> subscriber, String query)
unregisterTopicSubscriber in interface Subscriptionpublic void asset(Asset asset)
asset in interface Assetted<KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>>public Asset asset()
asset in interface Assetted<KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>>public void underlying(KeyValueStore underlying)
underlying in interface Assetted<KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>>public KeyValueStore underlying()
underlying in interface Assetted<KeyValueStore<String,net.openhft.chronicle.bytes.Bytes,net.openhft.chronicle.bytes.BytesStore>>Copyright © 2015. All rights reserved.