Something went wrong. Try again.
like malachite (atproto-lastfm-importer) but in go and bluer
go spotify tealfm lastfm atproto
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061package cache
import ( "os" "path/filepath" "strings" "time")
const ( CacheFile = "cache.db" CacheTTL = 24 * time.Hour)
type Entry[T any] struct { URI string `json:"uri"` CID string `json:"cid"` Value T `json:"value"`}
func recordsBucket(did string) string { return "records:" + did}
func processedBucket(did string) string { return "processed:" + did}
func failedBucket(did string) string { return "failed:" + did}
func metaBucket() string { return "_meta"}
const metaPrefixTimestamp = "ts:"
func cacheDir() (string, error) { if dir := os.Getenv("LAZULI_CACHE_DIR"); dir != "" { return dir, nil }
for _, arg := range os.Args { if strings.HasPrefix(arg, "-test.") { dir, err := os.MkdirTemp("", "lazuli-test-*") if err != nil { return "", err } os.Setenv("LAZULI_CACHE_DIR", dir) return dir, nil } }
cacheDir, err := os.UserCacheDir() if err != nil { return "", err } return filepath.Join(cacheDir, "lazuli"), nil}