Go to file
Lunny Xiao b49f55a46f
All checks were successful
test / check and test (push) Successful in 10m14s
Update CI (#16)
Reviewed-on: #16
2024-03-15 15:06:03 +00:00
.gitea/workflows Update CI (#16) 2024-03-15 15:06:03 +00:00
ledis Make linter happy (#13) 2022-05-16 20:12:27 +08:00
memcache Give each implementation it's own package (#11) 2022-05-16 01:57:21 +08:00
mysql Use blake2b as hash algorithm (#14) 2022-05-31 06:19:34 +08:00
nodb Make linter happy (#13) 2022-05-16 20:12:27 +08:00
postgres Use blake2b as hash algorithm (#14) 2022-05-31 06:19:34 +08:00
redis Give each implementation it's own package (#11) 2022-05-16 01:57:21 +08:00
.gitignore Rework tests & ci pipeline (#6) 2022-05-16 00:44:29 +08:00
cache_test.go Rework tests & ci pipeline (#6) 2022-05-16 00:44:29 +08:00
cache.go Update project aim and description (#10) 2022-05-16 01:21:06 +08:00
file_test.go Rework tests & ci pipeline (#6) 2022-05-16 00:44:29 +08:00
file.go Use blake2b as hash algorithm (#14) 2022-05-31 06:19:34 +08:00
go.mod Update CI (#16) 2024-03-15 15:06:03 +00:00
go.sum Update CI (#16) 2024-03-15 15:06:03 +00:00
LICENSE Initial commit 2014-07-15 18:38:44 -04:00
memory_test.go Add Ping to Interface (#4) 2022-05-16 00:54:59 +08:00
memory.go Make linter happy (#13) 2022-05-16 20:12:27 +08:00
README.md Update project aim and description (#10) 2022-05-16 01:21:06 +08:00
utils.go Make linter happy (#13) 2022-05-16 20:12:27 +08: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, file, Redis, Memcache, PostgreSQL, MySQL, Ledis and Nodb.

Installation

go get gitea.com/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 interface{}, timeout int64) error
	// Get gets cached value by given key.
	Get(key string) interface{}
	// 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-macaron/cache.

License

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