@@ -20,11 +20,6 @@ const (
20
20
TypeRedis Type = "redis"
21
21
)
22
22
23
- type Client struct {
24
- dir string
25
- Cache
26
- }
27
-
28
23
type Type string
29
24
30
25
type Options struct {
@@ -115,9 +110,8 @@ func NewType(backend string) (Type, error) {
115
110
}
116
111
}
117
112
118
- // NewClient returns a new cache client
119
- func NewClient (dir string , opts Options ) (* Client , error ) {
120
- client := & Client {dir : dir }
113
+ // New returns a new cache client
114
+ func New (dir string , opts Options ) (Cache , error ) {
121
115
if opts .Type == TypeRedis {
122
116
log .Info ("Redis cache" , log .String ("url" , opts .Redis .BackendMasked ()))
123
117
options , err := redis .ParseURL (opts .Redis .Backend )
@@ -142,38 +136,15 @@ func NewClient(dir string, opts Options) (*Client, error) {
142
136
}
143
137
}
144
138
145
- client .Cache = NewRedisCache (options , opts .TTL )
146
- return client , nil
139
+ return NewRedisCache (options , opts .TTL ), nil
147
140
}
148
141
149
142
// standalone mode
150
- var err error
151
- client .Cache , err = NewFSCache (dir )
143
+ fsCache , err := NewFSCache (dir )
152
144
if err != nil {
153
145
return nil , xerrors .Errorf ("unable to initialize fs cache: %w" , err )
154
146
}
155
- return client , nil
156
- }
157
-
158
- // Reset resets the cache
159
- func (c * Client ) Reset () error {
160
- log .Info ("Removing all caches..." )
161
- if err := c .Clear (); err != nil {
162
- return xerrors .Errorf ("failed to remove the cache: %w" , err )
163
- }
164
- if err := os .RemoveAll (c .dir ); err != nil {
165
- return xerrors .Errorf ("failed to remove the directory (%s) : %w" , c .dir , err )
166
- }
167
- return nil
168
- }
169
-
170
- // ClearArtifacts clears the artifact cache
171
- func (c * Client ) ClearArtifacts () error {
172
- log .Info ("Removing artifact caches..." )
173
- if err := c .Clear (); err != nil {
174
- return xerrors .Errorf ("failed to remove the cache: %w" , err )
175
- }
176
- return nil
147
+ return fsCache , nil
177
148
}
178
149
179
150
// GetTLSConfig gets tls config from CA, Cert and Key file
0 commit comments