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.
Description
Section titled “Description”Data stays as long as a resource uses it, then for expiry after its last access, within size entries.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
MemoryResourceCache | create() factory | Creates a cache without a size limit and with an expiry of 5 minutes. |
Properties
Section titled “Properties”| Property | Type | Default | Summary |
|---|---|---|---|
| size | int | 2147483647 | The number of entries kept after their last use; size(int) sets it and keeps the current entries. |
| expiry | long | 300000L | How long an entry stays after its last access, in milliseconds; expiry(long) sets it and keeps the current entries. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
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. |
Creation details
Section titled “Creation details”create
Section titled “create”MemoryResourceCache create() factory
Creates a cache without a size limit and with an expiry of 5 minutes.
Property details
Section titled “Property details”this size(int size)fluentint getSize()
Default: 2147483647
The number of entries kept after their last use; size(int) sets it and keeps the current entries.
expiry
Section titled “expiry”this expiry(long expiry)fluentlong getExpiry()
Default: 300000L
How long an entry stays after its last access, in milliseconds; expiry(long) sets it and keeps the current entries.
Method details
Section titled “Method details”void put(String uniqueId, ResourceData data)
Keeps data under uniqueId.
remove
Section titled “remove”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.
getDataList
Section titled “getDataList”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
