Cachex v3.1.3 Cachex.Query 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
create(any(), any()) :: [{tuple(), [tuple()], [any()]}]

Creates an expiration-aware query.

Link to this function expired(output \\ :"$_") View Source
expired(any()) :: [{tuple(), [tuple()], [any()]}]

Creates a query to retrieve all expired records.

Link to this function expired_clause() View Source
expired_clause() :: tuple()

Creates a match condition for expired records.

Link to this function raw(condition, output \\ :"$_") View Source
raw(any(), any()) :: [{tuple(), [tuple()], [any()]}]

Creates a raw query, ignoring expiration.

Link to this function unexpired(output \\ :"$_") View Source
unexpired(any()) :: [{tuple(), [tuple()], [any()]}]

Creates a query to retrieve all unexpired records.

Link to this function unexpired_clause() View Source
unexpired_clause() :: tuple()

Creates a match condition for unexpired records.