ACOR Documentation

Aho-Corasick on Redis, with one API across multiple topologies.

ACOR is a Go library and CLI for storing and querying Aho-Corasick patterns in Redis. It supports standalone Redis, Sentinel, Cluster, and Ring deployments through the same Create API.

Getting Started

ACOR requires Go 1.23 or newer and Redis 3.0 or newer.

go get -u github.com/skyoo2003/acor
package main

import (
  "fmt"

  "github.com/skyoo2003/acor/pkg/acor"
)

func main() {
  ac, err := acor.Create(&acor.AhoCorasickArgs{
    Addr: "localhost:6379",
    Name: "sample",
  })
  if err != nil {
    panic(err)
  }
  defer ac.Close()

  _, _ = ac.Add("he")
  _, _ = ac.Add("her")
  matched, _ := ac.Find("he is her")
  fmt.Println(matched)
}

Redis Topologies

sentinelArgs := &acor.AhoCorasickArgs{
  Addrs:      []string{"localhost:26379", "localhost:26380"},
  MasterName: "mymaster",
  Name:       "sample",
}

clusterArgs := &acor.AhoCorasickArgs{
  Addrs: []string{"localhost:7000", "localhost:7001", "localhost:7002"},
  Name:  "sample",
}

ringArgs := &acor.AhoCorasickArgs{
  RingAddrs: map[string]string{
    "shard-1": "localhost:7000",
    "shard-2": "localhost:7001",
  },
  Name: "sample",
}

CLI Commands

FlagPurpose
-addrStandalone Redis server address
-addrsSentinel or Cluster seed addresses
-master-nameRedis Sentinel master name
-ring-addrsComma-separated shard=addr pairs
-passwordRedis password
-dbRedis DB number
-namePattern collection name, default default
-debugEnable debug logging

HTTP and gRPC Adapters

The HTTP handler exposes JSON endpoints on /v1/* plus /healthz.

The gRPC service name is acor.server.v1.Acor and mirrors the same operations.

Development Workflow

Run local checks with:

make test
make build

CI runs on pushes and pull requests against master. Releases are tag-based, and the GitHub Pages site is built from the Hugo source in docs/.

Source code is MIT licensed. Contributions should include tests when behavior changes.