Skip to content

Instantly share code, notes, and snippets.

@ChrisBlom
ChrisBlom / Cached
Created September 29, 2023 09:30
how to wrap a function in Kotlin so that is invoked at most once in a duration for each argument
import com.github.benmanes.caffeine.cache.Caffeine
import com.github.benmanes.caffeine.cache.Ticker
import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Test
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicLong
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
import kotlin.time.toJavaDuration
@ChrisBlom
ChrisBlom / datomic-cdc.clj
Last active March 22, 2024 11:53
Datomic change data capture
(ns datomic-cdc.core
"proof-of-concept that shows how setup change-data-capture for datomic"
(:require [datomic.api :as d]))
(def processed-t- (atom nil))
(defn start-cdc-thread
"starts a new thread to processes all past transactions starting at start-t, then continues processing incoming transactions, using the provided `change-handler`
`change-handler` must be a function that takes a single map argument with