CacheKey

class CacheKey<V : Any>(val endpointId: String, params: List<Pair<String, String>>)(source)

Identifies one cached answer: an endpoint id and the endpoint's parameters, and nothing else.

Stable Core. Equality is on endpointId and params only; the type parameter V is a phantom, so one endpoint id serves one value type and a second type under the same id is a programming error (the consumer's use of the value fails with a ClassCastException). Names, values and the id are case-sensitive and compared as UTF-16 code units; there is no Unicode normalisation. Never put a tenant, a header, a credential or the decoder in a key: the key is an equality key and is printed (names only) in logs. toString() prints the id and the parameter names, never a value.

Parameters

endpointId

the endpoint's stable id; not blank.

params

the endpoint's parameters as name/value pairs, in any order; copied and sorted by name with a stable sort, so repeated names keep the caller's order.

Type Parameters

V

the value type this key's endpoint returns (not part of equality).

Throws

Constructors

Link copied to clipboard
constructor(endpointId: String, params: List<Pair<String, String>>)
constructor(endpointId: String)

A key with no parameters.

Properties

Link copied to clipboard

The endpoint's stable id.

Link copied to clipboard

The parameters, sorted by name (stable: repeated names keep the caller's order). A read-only copy.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Two CacheKeys are equal when their endpointId and params are equal; the type parameter takes no part.

Link copied to clipboard
open override fun hashCode(): Int

Returns a hash code consistent with equals: it is computed from the same properties. It is computed once, at construction.

Link copied to clipboard
open override fun toString(): String

A diagnostic string for logs: endpointId and the parameter names, never a value. Its format is not part of the API and may change.