Module methanol

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

    • executor

      public Optional<Executor> executor()
      Description copied from interface: Store
      Returns the optional executor used for asynchronous or background operations.
      Specified by:
      executor in interface Store
    • 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
      Returns a Optional<Viewer> for the entry associated with the given key, or an empty optional 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
      Returns an Optional<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.
      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 modified, but there's no guarantee these 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 will silently fail 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 data buffered by this store.
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in interface Store