Class Cache

All Implemented Interfaces:
SessionFeature, Proxy

@Generated("org.javagi.JavaGI") public class Cache extends GObject implements SessionFeature
File-based cache for HTTP resources.
  • Constructor Details

    • Cache

      public Cache(MemorySegment address)
      Create a Cache instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Cache

      public Cache(@Nullable String cacheDir, CacheType cacheType)
      Creates a new SoupCache.
      Parameters:
      cacheDir - the directory to store the cached data, or null to use the default one. Note that since the cache isn't safe to access for multiple processes at once, and the default directory isn't namespaced by process, clients are strongly discouraged from passing null.
      cacheType - the SoupCacheType of the cache
    • Cache

      public Cache()
      Create a new Cache.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Cache class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected Cache asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • clear

      public void clear()

      Will remove all entries in the this Cache plus all the cache files.

      This is not thread safe and must be called only from the thread that created the Cache

    • dump

      public void dump()

      Synchronously writes the cache index out to disk.

      Contrast with flush(), which writes pending cache entries to disk.

      You must call this before exiting if you want your cache data to persist between sessions.

      This is not thread safe and must be called only from the thread that created the Cache

    • flush

      public void flush()

      Forces all pending writes in the this Cache to be committed to disk.

      For doing so it will iterate the GLib.MainContext associated with cache's session as long as needed.

      Contrast with dump(), which writes out the cache index file.

    • getMaxSize

      public int getMaxSize()
      Gets the maximum size of the cache.
      Returns:
      the maximum size of the cache, in bytes.
    • load

      public void load()

      Loads the contents of cache's index into memory.

      This is not thread safe and must be called only from the thread that created the Cache

    • setMaxSize

      public void setMaxSize(int maxSize)
      Sets the maximum size of the cache.
      Parameters:
      maxSize - the maximum size of the cache, in bytes
    • getCacheability

      protected Set<Cacheability> getCacheability(Message msg)
    • builder

      public static Cache.Builder<? extends Cache.Builder> builder()
      A Cache.Builder object constructs a Cache with the specified properties. Use the various set...() methods to set properties, and finish construction with Cache.Builder.build().
      Returns:
      the builder object