No description
Find a file
Renovate Bot 458389c6b5
All checks were successful
test / test (push) Successful in 34s
Update dependency go to v1.25.6 (#49)
Reviewed-on: #49
Reviewed-by: Gusted <gusted@noreply.code.forgejo.org>
Co-authored-by: Renovate Bot <bot@kriese.eu>
Co-committed-by: Renovate Bot <bot@kriese.eu>
2026-01-17 13:58:01 +00:00
.forgejo/workflows Update module golangci-lint to v2.8.0 (#48) 2026-01-11 08:41:17 +00:00
memcache Update module golangci-lint to v2.6.0 (#37) 2025-10-31 23:43:13 +00:00
.golangci.yaml Update module golangci-lint to v2.6.0 (#37) 2025-10-31 23:43:13 +00:00
cache.go [REFACTOR] Use any 2024-08-26 19:43:31 +02:00
cache_test.go [PORT] Ignore not exist key with memcache (gitea#17) 2024-09-12 12:36:40 +02:00
go.mod Update dependency go to v1.25.6 (#49) 2026-01-17 13:58:01 +00:00
go.sum Update module github.com/stretchr/testify to v1.11.0 (#28) 2025-08-26 20:48:19 +00:00
LICENSE Initial commit 2014-07-15 18:38:44 -04:00
memory.go [FEAT] Make it data-race proof 2024-08-27 21:21:27 +02:00
memory_test.go [CHORE] Add lint 2024-08-26 19:37:33 +02:00
README.md [CHORE] Branding 2024-08-26 06:05:21 +02:00
renovate.json chore(renovate): use shared org preset 2024-11-07 15:29:16 +01:00
utils.go [CHORE] Remove unused cache adapters 2024-08-26 06:05:17 +02:00

cache

cache is a middleware that aim to have a transparent interface for a lot of cache implementations.

Use use many cache adapters, including memory and Memcache.

Installation

go get code.forgejo.org/go-chi/cache

Getting Help

// Cache is the interface that operates the cache data.
type Cache interface {
	// Put puts value into cache with key and expire time.
	Put(key string, val any, timeout int64) error
	// Get gets cached value by given key.
	Get(key string) any
	// Delete deletes cached value by given key.
	Delete(key string) error
	// Incr increases cached int-type value by given key as a counter.
	Incr(key string) error
	// Decr decreases cached int-type value by given key as a counter.
	Decr(key string) error
	// IsExist returns true if cached value exists.
	IsExist(key string) bool
	// Flush deletes all cached data.
	Flush() error
	// StartAndGC starts GC routine based on config string settings.
	StartAndGC(opt Options) error
	// Ping tests if the cache is alive
	Ping() error
}

Credits

This package is a modified version of go-chi/cache which is a modified version of go-macaron/cache.

License

This project is under the Apache License, Version 2.0. See the LICENSE file for the full license text.