2017-10-23 20:42:56 +00:00
|
|
|
package physical
|
|
|
|
|
2018-09-18 03:03:00 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
2018-01-19 06:44:44 +00:00
|
|
|
|
2017-10-23 20:42:56 +00:00
|
|
|
// PhysicalAccess is a wrapper around physical.Backend that allows Core to
|
|
|
|
// expose its physical storage operations through PhysicalAccess() while
|
|
|
|
// restricting the ability to modify Core.physical itself.
|
|
|
|
type PhysicalAccess struct {
|
|
|
|
physical Backend
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ Backend = (*PhysicalAccess)(nil)
|
|
|
|
|
|
|
|
func NewPhysicalAccess(physical Backend) *PhysicalAccess {
|
|
|
|
return &PhysicalAccess{physical: physical}
|
|
|
|
}
|
|
|
|
|
2018-01-19 06:44:44 +00:00
|
|
|
func (p *PhysicalAccess) Put(ctx context.Context, entry *Entry) error {
|
|
|
|
return p.physical.Put(ctx, entry)
|
2017-10-23 20:42:56 +00:00
|
|
|
}
|
|
|
|
|
2018-01-19 06:44:44 +00:00
|
|
|
func (p *PhysicalAccess) Get(ctx context.Context, key string) (*Entry, error) {
|
|
|
|
return p.physical.Get(ctx, key)
|
2017-10-23 20:42:56 +00:00
|
|
|
}
|
|
|
|
|
2018-01-19 06:44:44 +00:00
|
|
|
func (p *PhysicalAccess) Delete(ctx context.Context, key string) error {
|
|
|
|
return p.physical.Delete(ctx, key)
|
2017-10-23 20:42:56 +00:00
|
|
|
}
|
|
|
|
|
2018-01-19 06:44:44 +00:00
|
|
|
func (p *PhysicalAccess) List(ctx context.Context, prefix string) ([]string, error) {
|
|
|
|
return p.physical.List(ctx, prefix)
|
2017-10-23 20:42:56 +00:00
|
|
|
}
|
|
|
|
|
2018-01-19 06:44:44 +00:00
|
|
|
func (p *PhysicalAccess) Purge(ctx context.Context) {
|
2018-01-26 03:21:51 +00:00
|
|
|
if purgeable, ok := p.physical.(ToggleablePurgemonster); ok {
|
2018-01-19 06:44:44 +00:00
|
|
|
purgeable.Purge(ctx)
|
2017-10-23 20:42:56 +00:00
|
|
|
}
|
|
|
|
}
|