Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added closure arg types to Cache/CachedValue documentation #418

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/main/groovy/io/xh/hoist/cache/Cache.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,27 @@ class Cache<K, V> implements LogSupport {
/** Unique name in the context of the service associated with this object. */
public final String name

/** Closure to determine if an entry should be expired (optional). */
/**
* Closure { CacheEntry<V> -> Boolean } to determine if an entry should be expired (optional).
*/
public final Closure<Boolean> expireFn

/**
* Entry TTL as epochMillis Long, or closure to return the same (optional).
* Entry TTL as epochMillis Long, or closure { void -> Long } to return the same (optional).
* No effect if a custom expireFn is provided instead. If both null, entries will never expire.
*/
public final Object expireTime

/**
* Closure to determine the timestamp of an entry (optional).
* Closure { V -> Long | Date | Instant } to determine the timestamp of an entry (optional).
* Must return a Long (as epochMillis), Date, or Instant.
*/
public final Closure timestampFn

/** True to replicate this cache across a cluster (default false). */
public final boolean replicate

/** Handlers to be called on change with a {@link CacheEntryChanged} */
/** Handler closures { CacheEntryChanged<K, V> -> void } to be called on change. */
public final List<Closure> onChange = []

/**
Expand Down
11 changes: 7 additions & 4 deletions src/main/groovy/io/xh/hoist/cachedvalue/CachedValue.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,28 @@ class CachedValue<V> implements LogSupport {
/** Unique name in the context of the service associated with this object. */
public final String name

/** Closure to determine if an entry should be expired (optional). */
/**
* Closure { CachedValueEntry<V> -> Boolean } to determine if an entry should
* be expired (optional).
*/
public final Closure<Boolean> expireFn

/**
* Entry TTL as epochMillis Long, or closure to return the same (optional).
* Entry TTL as epochMillis Long, or closure { void -> Long } to return the same (optional).
* No effect if a custom expireFn is provided instead. If both null, entries will never expire.
*/
public final Object expireTime

/**
* Closure to determine the timestamp of an entry (optional).
* Closure { V -> Long | Date | Instant } to determine the timestamp of an entry (optional).
* Must return a Long (as epochMillis), Date, or Instant.
*/
public final Closure timestampFn

/** True to replicate this cache across a cluster (default false). */
public final boolean replicate

/** Handlers to be called on change with a {@link CachedValueChanged} object. */
/** Handler closures { CachedValueChanged<V> -> void } to be called on change. */
public final List<Closure> onChange = []


Expand Down
Loading