-
Notifications
You must be signed in to change notification settings - Fork 0
/
nop.go
53 lines (43 loc) · 1.07 KB
/
nop.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package filecache
import (
"context"
"io"
"os"
"strings"
)
// NewNop creates no-operation file cache instance.
func NewNop() FileCache {
return &nopFileCache{}
}
type nopFileCache struct{}
func (fc *nopFileCache) GetPath() string {
return os.TempDir()
}
func (fc *nopFileCache) Write(_ context.Context, _ string, _ io.Reader, _ ...ItemOptions) (written int64, err error) {
return 0, nil
}
func (fc *nopFileCache) WriteData(_ context.Context, _ string, _ []byte, _ ...ItemOptions) (written int64, err error) {
return 0, nil
}
func (fc *nopFileCache) Open(_ context.Context, _ string) (result *OpenResult, err error) {
return &OpenResult{
hit: true,
reader: io.NopCloser(
strings.NewReader(""),
),
options: &ItemOptions{},
}, nil
}
func (fc *nopFileCache) Read(_ context.Context, _ string) (result *ReadResult, err error) {
return &ReadResult{
hit: true,
data: []byte(""),
options: &ItemOptions{},
}, nil
}
func (fc *nopFileCache) Invalidate(_ context.Context, _ string) error {
return nil
}
func (fc *nopFileCache) Close() error {
return nil
}