Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

22 wiersze
495 B

3 lat temu
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
}
}