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
425 B
22 lines
425 B
package ns
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"gitoa.ru/go-4devs/cache"
|
|
)
|
|
|
|
var ErrProviderNotFound = errors.New("provider not found")
|
|
|
|
func New(providers map[string]cache.Provider) cache.Provider {
|
|
return func(ctx context.Context, operation string, item *cache.Item) error {
|
|
if prov, ok := providers[item.Key.Prefix]; ok {
|
|
item.Key.Prefix = ""
|
|
|
|
return prov(ctx, operation, item)
|
|
}
|
|
|
|
return ErrProviderNotFound
|
|
}
|
|
}
|
|
|