You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
495B

  1. package cache
  2. import "context"
  3. // available operation.
  4. const (
  5. OperationGet = "get"
  6. OperationSet = "set"
  7. OperationDelete = "delete"
  8. )
  9. // OperationProvider creating a provider based on available operations.
  10. func OperationProvider(prov map[string]func(ctx context.Context, item *Item) error) Provider {
  11. return func(ctx context.Context, operation string, item *Item) error {
  12. if method, ok := prov[operation]; ok {
  13. return method(ctx, item)
  14. }
  15. return ErrOperationNotAllwed
  16. }
  17. }