Skip to content
Kevin Souza edited this page Mar 18, 2024 · 6 revisions

The cache package provides an interface to interact with different cache stores, like BigCache and Redis.

Cache is optional, you can pass nil when building the equinox client to disable caching. The default client has cache enabled using BigCache.

You can interact with the cache from the equinox client:

client, err := equinox.NewClient("RIOT_API_KEY")
// Methods available: Get, Set, Delete and Clear.
body, err := client.Cache.Get("https://euw1.api.riotgames.com/...") // []byte, error

Stores

Examples

BigCache

ctx := context.Background()
cacheConfig := bigcache.DefaultConfig(4 * time.Minute)
cache, err := cache.NewBigCache(ctx, cacheConfig)

Redis

ctx := context.Background()
config := &redis.Options{
	Network: "tcp",
	Addr:    "127.0.0.1",
}
cache, err := cache.NewRedis(ctx, config, 4*time.Minute)
Clone this wiki locally