Aho-Corasick automaton working On Redis — distributed multi-pattern matching for Go.
ACOR keeps one Aho-Corasick dictionary in Redis and reaches it from a Go library, a CLI, and an experimental server module. Every application instance shares that dictionary, updates it at runtime, and matches against a local copy with no Redis I/O on the hot path.
Typical uses: content filtering, keyword extraction, intrusion detection, search highlighting, real-time text classification.
- Shared state — every instance reads the same Redis-backed dictionary
- Runtime updates — Pub/Sub invalidation, with optional polling for missed messages
- Fast reads — preset engines match locally, 0 round trips
- Topologies — standalone Redis, Sentinel, Cluster, Ring, and Valkey
- Full matching API — occurrences, positions, sets, streams, batches, parallel scans
Requires Go 1.25+ and Redis 3.0+ or Valkey 7.2+.
go get github.com/skyoo2003/acor/pkg/acor@latestStart Redis locally, then:
package main
import (
"fmt"
"github.com/skyoo2003/acor/pkg/acor"
)
func main() {
ac, err := acor.Create(&acor.AhoCorasickArgs{
Addr: "localhost:6379",
Name: "sample",
Preset: acor.PresetBalanced,
})
if err != nil {
panic(err)
}
defer ac.Close()
if _, err := ac.AddMany([]string{"he", "her", "him"}, nil); err != nil {
panic(err)
}
matches, err := ac.Find("he is him")
if err != nil {
panic(err)
}
fmt.Println(matches)
}New collections use the optimized V2 Redis schema.
| Goal | Preset |
|---|---|
| General-purpose speed and memory | PresetBalanced |
| Highest matching throughput | PresetSpeed |
| Lowest memory usage | PresetMemoryEfficient |
Redis stays the source of truth for every preset. Trade-offs are in the preset guide; multi-instance invalidation is in the Redis-backed engine guide.
OpenVersioned opens a separate V3 collection with leased snapshots, expected-version
writes, and background engine replacement. V1/V2 APIs are unaffected. See the
V3 guide, its
performance report, and
bounded text processing for Scan,
MaskText, and ReplaceText.
The documentation site covers Redis topologies, the
matching and streaming API, batch and parallel guides, the V2 schema and benchmarks,
deployment and troubleshooting, the acor CLI, the experimental server module, and what
the v1 line promises. Package signatures are on
pkg.go.dev.
Contributing · Support · Security · Code of Conduct · Governance · Changelog
Apache License 2.0 — Copyright 2016-2026 Sungkyu Yoo