Class MemoryStore

java.lang.Object
com.github.mizosoft.methanol.internal.cache.MemoryStore
All Implemented Interfaces:
Store, Closeable, Flushable, AutoCloseable

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

    • MemoryStore

      public MemoryStore(long maxSize)
  • Method Details

    • 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 Optional<Store.Viewer> view(String key)
      Description copied from interface: Store
      Synchronous variant of Store.view(String, Executor).
      Specified by:
      view in interface Store
    • view

      public CompletableFuture<Optional<Store.Viewer>> view(String key, 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 Optional<Store.Editor> edit(String key)
      Description copied from interface: Store
      Synchronous variant of Store.edit(String, Executor).
      Specified by:
      edit in interface Store
    • edit

      public CompletableFuture<Optional<Store.Editor>> edit(String key, 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 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(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 AutoCloseable
      Specified by:
      close in interface 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 Flushable
      Specified by:
      flush in interface Store
    • toString

      public String toString()
      Overrides:
      toString in class Object