Cachex.Query (Cachex v3.4.0) View Source

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

Specs

create(any(), any()) :: [{tuple(), [tuple()], [any()]}]

Creates an expiration-aware query.

Link to this function

expired(output \\ :"$_")

View Source

Specs

expired(any()) :: [{tuple(), [tuple()], [any()]}]

Creates a query to retrieve all expired records.

Specs

expired_clause() :: tuple()

Creates a match condition for expired records.

Link to this function

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

View Source

Specs

raw(any(), any()) :: [{tuple(), [tuple()], [any()]}]

Creates a raw query, ignoring expiration.

Link to this function

unexpired(output \\ :"$_")

View Source

Specs

unexpired(any()) :: [{tuple(), [tuple()], [any()]}]

Creates a query to retrieve all unexpired records.

Specs

unexpired_clause() :: tuple()

Creates a match condition for unexpired records.