View Source Cachex.Query (Cachex v3.6.0)

Utility module based around creation of cache queries.

Queries are essentially just some minor convenience wrappers around the internal match specification used by ETS. This module is exposed to make it easier to query a cache (via Cachex.stream/3) without having to take care of filtering for expirations by hand.

Note that there is almost no validation in here, so test thoroughly and store compile-time versions of your queries when possible (as performance is not taken into account inside this module; it can be slow to generate).

Link to this section Summary

Functions

Creates an expiration-aware query.

Creates a query to retrieve all expired records.

Creates a match condition for expired records.

Creates a raw query, ignoring expiration.

Creates a query to retrieve all unexpired records.

Creates a match condition for unexpired records.

Link to this section Functions

Link to this function

create(condition, output \\ :"$_")

View Source
@spec create(any(), any()) :: [{tuple(), [tuple()], [any()]}]

Creates an expiration-aware query.

Link to this function

expired(output \\ :"$_")

View Source
@spec expired(any()) :: [{tuple(), [tuple()], [any()]}]

Creates a query to retrieve all expired records.

@spec expired_clause() :: tuple()

Creates a match condition for expired records.

Link to this function

raw(condition, output \\ :"$_")

View Source
@spec raw(any(), any()) :: [{tuple(), [tuple()], [any()]}]

Creates a raw query, ignoring expiration.

Link to this function

unexpired(output \\ :"$_")

View Source
@spec unexpired(any()) :: [{tuple(), [tuple()], [any()]}]

Creates a query to retrieve all unexpired records.

@spec unexpired_clause() :: tuple()

Creates a match condition for unexpired records.