mirror of
https://github.com/xaionaro-go/streamctl.git
synced 2025-10-05 15:37:00 +08:00
25 lines
359 B
Go
25 lines
359 B
Go
package memoize
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type CtxKey string
|
|
|
|
const (
|
|
CtxKeyNoCache = CtxKey("no_cache")
|
|
)
|
|
|
|
func IsNoCache(ctx context.Context) bool {
|
|
v := ctx.Value(CtxKeyNoCache)
|
|
if v == nil {
|
|
return false
|
|
}
|
|
b, _ := v.(bool)
|
|
return b
|
|
}
|
|
|
|
func SetNoCache(ctx context.Context, b bool) context.Context {
|
|
return context.WithValue(ctx, CtxKeyNoCache, b)
|
|
}
|