mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 12:21:03 +00:00
20c1ca6e33
set the cache to 30m instead of 24h until we have a way to flush from the UI
39 lines
849 B
Go
39 lines
849 B
Go
package cache
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/koding/cache"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
type Cache interface {
|
|
Get(string) (interface{}, error)
|
|
Set(string, interface{}) error
|
|
}
|
|
|
|
func Get(c context.Context, key string) (interface{}, error) {
|
|
return FromContext(c).Get(key)
|
|
}
|
|
|
|
func Set(c context.Context, key string, value interface{}) error {
|
|
return FromContext(c).Set(key, value)
|
|
}
|
|
|
|
// Default creates an in-memory cache with the default
|
|
// 30 minute expiration period.
|
|
func Default() Cache {
|
|
return cache.NewMemoryWithTTL(time.Minute * 30)
|
|
}
|
|
|
|
// NewTTL returns an in-memory cache with the specified
|
|
// ttl expiration period.
|
|
func NewTTL(t time.Duration) Cache {
|
|
return cache.NewMemoryWithTTL(t)
|
|
}
|
|
|
|
// NewTTL returns an in-memory cache with the specified
|
|
// ttl expiration period.
|
|
func NewLRU(size int) Cache {
|
|
return cache.NewLRU(size)
|
|
}
|