Database persistence for audience definitions and memberships.
Implements IAudienceRepository using next.jdbc + HoneySQL.
Column layout for audience_segments: audience_id VARCHAR — keyword name (e.g. "premium-users") filters TEXT/JSONB — serialised as JSON tags TEXT/JSONB — serialised as JSON composition TEXT/JSONB — optional, serialised as JSON cache_config TEXT/JSONB — optional, serialised as JSON
JSON columns use cheshire for serialisation. On PostgreSQL the
columns are JSONB; on H2 (tests) they are stored as TEXT — both
are handled by ->json below.
Database persistence for audience definitions and memberships. Implements IAudienceRepository using next.jdbc + HoneySQL. Column layout for audience_segments: audience_id VARCHAR — keyword name (e.g. "premium-users") filters TEXT/JSONB — serialised as JSON tags TEXT/JSONB — serialised as JSON composition TEXT/JSONB — optional, serialised as JSON cache_config TEXT/JSONB — optional, serialised as JSON JSON columns use cheshire for serialisation. On PostgreSQL the columns are JSONB; on H2 (tests) they are stored as TEXT — both are handled by `->json` below.
(clear-memberships! datasource audience-id)Delete all membership records for the given audience.
Args: datasource - javax.sql.DataSource audience-id - keyword
Returns: nil
Delete all membership records for the given audience. Args: datasource - javax.sql.DataSource audience-id - keyword Returns: nil
(create-audience-store datasource)Create an AudienceStore backed by a JDBC datasource.
Args: datasource - javax.sql.DataSource (HikariCP pool or plain)
Returns: AudienceStore implementing IAudienceRepository
Create an AudienceStore backed by a JDBC datasource. Args: datasource - javax.sql.DataSource (HikariCP pool or plain) Returns: AudienceStore implementing IAudienceRepository
(get-memberships datasource audience-id)Return all user UUIDs that are members of the given audience.
Args: datasource - javax.sql.DataSource audience-id - keyword
Returns: Vector of java.util.UUID, or [] if the segment does not exist
Return all user UUIDs that are members of the given audience. Args: datasource - javax.sql.DataSource audience-id - keyword Returns: Vector of java.util.UUID, or [] if the segment does not exist
(save-memberships! datasource audience-id user-ids)Batch-insert user UUIDs into audience_memberships for an audience.
Idempotent: one SELECT fetches the audience's existing user-ids, the already-present ids are removed in memory, and only the missing ones are inserted via chunked multi-row INSERTs — all inside a single transaction. This keeps the SQL portable across H2 and PostgreSQL (no ON CONFLICT) and avoids per-user round-trips.
Args: datasource - javax.sql.DataSource audience-id - keyword (e.g. :premium-users) user-ids - collection of java.util.UUID
Returns: nil
Batch-insert user UUIDs into audience_memberships for an audience. Idempotent: one SELECT fetches the audience's existing user-ids, the already-present ids are removed in memory, and only the missing ones are inserted via chunked multi-row INSERTs — all inside a single transaction. This keeps the SQL portable across H2 and PostgreSQL (no ON CONFLICT) and avoids per-user round-trips. Args: datasource - javax.sql.DataSource audience-id - keyword (e.g. :premium-users) user-ids - collection of java.util.UUID Returns: nil
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |