java.lang.Object
com.github.mizosoft.methanol.internal.cache.MemoryStore
- All Implemented Interfaces:
Store
,Closeable
,Flushable
,AutoCloseable
Store
implementation that stores entries in memory.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.github.mizosoft.methanol.internal.cache.Store
Store.Editor, Store.EntryReader, Store.EntryWriter, Store.Viewer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all entries from this store.void
close()
Closes this store.void
dispose()
Atomically clears and closes this store.Returns anOptional<Editor>
for the entry associated with the given key (atomically creating a new one if necessary), or an empty optional if such entry can't be edited.executor()
Returns the optional executor used for asynchronous or background operations.void
flush()
Flushes any data buffered by this store.iterator()
Returns an iterator ofViewers
over the entries in this store.long
maxSize()
Returns this store's max size in bytes.boolean
Removes the entry associated with the given key.long
size()
Returns the size in bytes of all entries in this store.Returns aOptional<Viewer>
for the entry associated with the given key, or an empty optional if there's no such entry.
-
Constructor Details
-
MemoryStore
public MemoryStore(long maxSize)
-
-
Method Details
-
executor
Description copied from interface:Store
Returns the optional executor used for asynchronous or background operations. -
maxSize
public long maxSize()Description copied from interface:Store
Returns this store's max size in bytes. -
size
public long size()Description copied from interface:Store
Returns the size in bytes of all entries in this store. -
view
Description copied from interface:Store
Returns aOptional<Viewer>
for the entry associated with the given key, or an empty optional if there's no such entry. -
edit
Description copied from interface:Store
Returns anOptional<Editor>
for the entry associated with the given key (atomically creating a new one if necessary), or an empty optional if such entry can't be edited. -
iterator
Description copied from interface:Store
Returns an iterator ofViewers
over the entries in this store. The iterator doesn't throwConcurrentModificationException
when the store is modified, but there's no guarantee these changes are reflected. -
remove
Description copied from interface:Store
Removes the entry associated with the given key. -
clear
public void clear()Description copied from interface:Store
Removes all entries from this store. -
dispose
public void dispose()Description copied from interface:Store
Atomically clears and closes this store. -
close
public void close()Description copied from interface:Store
Closes this store. Once the store is closed, all ongoing edits will silently fail to write or commit anything. -
flush
public void flush()Description copied from interface:Store
Flushes any data buffered by this store.
-