Module methanol

Class MemoryStore

  • All Implemented Interfaces:
    Store, java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public final class MemoryStore
    extends java.lang.Object
    implements Store
    Store implementation that stores entries in memory.
    • Constructor Summary

      Constructors 
      Constructor Description
      MemoryStore​(long maxSize)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Removes all entries from this store.
      void close()
      Closes this store.
      void dispose()
      Atomically clears and closes this store.
      java.util.Optional<Store.Editor> edit​(java.lang.String key)
      Synchronous variant of Store.edit(String, Executor).
      java.util.concurrent.CompletableFuture<java.util.Optional<Store.Editor>> edit​(java.lang.String key, java.util.concurrent.Executor executor)
      Opens an editor for the entry associated with the given key.
      void flush()
      Flushes any indexing data buffered by this store.
      java.util.Iterator<Store.Viewer> iterator()
      Returns an iterator of Viewers over the entries in this store.
      long maxSize()
      Returns this store's max size in bytes.
      boolean remove​(java.lang.String key)
      Removes the entry associated with the given key.
      long size()
      Returns the size in bytes of all entries in this store.
      java.lang.String toString()  
      java.util.Optional<Store.Viewer> view​(java.lang.String key)
      Synchronous variant of Store.view(String, Executor).
      java.util.concurrent.CompletableFuture<java.util.Optional<Store.Viewer>> view​(java.lang.String key, java.util.concurrent.Executor executor)
      Opens a viewer for the entry associated with the given key.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.github.mizosoft.methanol.internal.cache.Store

        removeAll
    • Constructor Detail

      • MemoryStore

        public MemoryStore​(long maxSize)
    • Method Detail

      • maxSize

        public long maxSize()
        Description copied from interface: Store
        Returns this store's max size in bytes.
        Specified by:
        maxSize in interface Store
      • size

        public long size()
        Description copied from interface: Store
        Returns the size in bytes of all entries in this store.
        Specified by:
        size in interface Store
      • view

        public java.util.concurrent.CompletableFuture<java.util.Optional<Store.Viewer>> view​(java.lang.String key,
                                                                                             java.util.concurrent.Executor executor)
        Description copied from interface: Store
        Opens a viewer for the entry associated with the given key. An empty optional is returned if there's no such entry.
        Specified by:
        view in interface Store
      • edit

        public java.util.concurrent.CompletableFuture<java.util.Optional<Store.Editor>> edit​(java.lang.String key,
                                                                                             java.util.concurrent.Executor executor)
        Description copied from interface: Store
        Opens an editor for the entry associated with the given key. An empty optional is returned either if there's no such entry, or such entry cannot be edited at the moment.
        Specified by:
        edit in interface Store
      • iterator

        public java.util.Iterator<Store.Viewer> iterator()
        Description copied from interface: Store
        Returns an iterator of Viewers over the entries in this store. The iterator doesn't throw ConcurrentModificationException when the store is asynchronously modified, but there's no guarantee such changes are reflected.
        Specified by:
        iterator in interface Store
      • remove

        public boolean remove​(java.lang.String key)
        Description copied from interface: Store
        Removes the entry associated with the given key.
        Specified by:
        remove in interface Store
      • clear

        public void clear()
        Description copied from interface: Store
        Removes all entries from this store.
        Specified by:
        clear in interface Store
      • dispose

        public void dispose()
        Description copied from interface: Store
        Atomically clears and closes this store.
        Specified by:
        dispose in interface Store
      • close

        public void close()
        Description copied from interface: Store
        Closes this store. Once the store is closed, all ongoing edits fail, either silently or by throwing an exception, to write or commit anything.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface Store
      • flush

        public void flush()
        Description copied from interface: Store
        Flushes any indexing data buffered by this store.
        Specified by:
        flush in interface java.io.Flushable
        Specified by:
        flush in interface Store
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object