Skip to content

MemoryResourceCache

final class MemoryResourceCache
Implements: IResourceCache
Package: dev.joid.lib.resource.cache · Module: core · Source: MemoryResourceCache.java

The default resource cache, which keeps the data in memory while it is used and for a while after.

Data stays as long as a resource uses it, then for expiry after its last access, within size entries.

ReturnsSignatureSummary
MemoryResourceCachecreate() factoryCreates a cache without a size limit and with an expiry of 5 minutes.

PropertyTypeDefaultSummary
sizeint2147483647The number of entries kept after their last use; size(int) sets it and keeps the current entries.
expirylong300000LHow long an entry stays after its last access, in milliseconds; expiry(long) sets it and keeps the current entries.

ReturnsSignatureSummary
voidput(String uniqueId, ResourceData data)Keeps data under uniqueId.
voidremove(String uniqueId)Forgets the data of uniqueId.
voidclear()Forgets every data.
ResourceDataget(String uniqueId)Returns the data of uniqueId while it is cached or still used by a resource, or null.
Collection<ResourceData>getDataList()Returns the data kept by the size and expiry rules, as a new list.

MemoryResourceCache create() factory

Creates a cache without a size limit and with an expiry of 5 minutes.

  • this size(int size) fluent
  • int getSize()

Default: 2147483647

The number of entries kept after their last use; size(int) sets it and keeps the current entries.

  • this expiry(long expiry) fluent
  • long getExpiry()

Default: 300000L

How long an entry stays after its last access, in milliseconds; expiry(long) sets it and keeps the current entries.

void put(String uniqueId, ResourceData data)

Keeps data under uniqueId.

void remove(String uniqueId)

Forgets the data of uniqueId.

void clear()

Forgets every data.

ResourceData get(String uniqueId)

Returns the data of uniqueId while it is cached or still used by a resource, or null.

Collection<ResourceData> getDataList()

Returns the data kept by the size and expiry rules, as a new list.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page