kafka/config.example.toml
Franz Kafka 94322ceff4 feat: Valkey cache for search results
- Add internal/cache package using go-redis/v9 (Valkey-compatible)
- Cache keys are deterministic SHA-256 hashes of search parameters
- Cache wraps the Search() method: check cache → miss → execute → store
- Gracefully disabled if Valkey is unreachable or unconfigured
- Configurable TTL (default 5m), address, password, and DB index
- Environment variable overrides: VALKEY_ADDRESS, VALKEY_PASSWORD,
  VALKEY_DB, VALKEY_CACHE_TTL
- Structured JSON logging via slog throughout cache layer
- Refactored service.go: extract executeSearch() from Search() for clarity
- Update config.example.toml with [cache] section
- Add cache package tests (key generation, nop behavior)
2026-03-21 15:43:47 +00:00

43 lines
1.2 KiB
TOML

# gosearch configuration
# Copy to config.toml and adjust as needed.
# Environment variables are used as fallbacks when a config field is empty/unset.
[server]
# Listen port (env: PORT)
port = 8080
# HTTP timeout for engine and upstream calls (env: HTTP_TIMEOUT)
http_timeout = "10s"
[upstream]
# URL of an upstream SearXNG instance for unported engines (env: UPSTREAM_SEARXNG_URL)
# Leave empty to run without an upstream proxy.
url = ""
[engines]
# Comma-separated list of engines to execute locally in Go (env: LOCAL_PORTED_ENGINES)
# Engines not listed here will be proxied to upstream SearXNG.
local_ported = ["wikipedia", "arxiv", "crossref", "braveapi", "qwant"]
[engines.brave]
# Brave Search API key (env: BRAVE_API_KEY)
api_key = ""
# Optional access token to gate requests (env: BRAVE_ACCESS_TOKEN)
access_token = ""
[engines.qwant]
# Qwant category: "web" or "web-lite" (default: "web-lite")
category = "web-lite"
results_per_page = 10
[cache]
# Valkey/Redis cache for search results.
# Leave address empty to disable caching entirely.
# Env: VALKEY_ADDRESS
address = ""
# Env: VALKEY_PASSWORD
password = ""
# Database index (env: VALKEY_DB)
db = 0
# Cache TTL for search results (env: VALKEY_CACHE_TTL)
default_ttl = "5m"