您最多能選擇 25 個主題 主題必須以字母或數字為開頭,可包含連接號「-」且最長為 35 個字元。

21 行
495 B

package cache
import "context"
// available operation.
const (
OperationGet = "get"
OperationSet = "set"
OperationDelete = "delete"
)
// OperationProvider creating a provider based on available operations.
func OperationProvider(prov map[string]func(ctx context.Context, item *Item) error) Provider {
return func(ctx context.Context, operation string, item *Item) error {
if method, ok := prov[operation]; ok {
return method(ctx, item)
}
return ErrOperationNotAllwed
}
}