• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

effective-security / porto / 20027296451

08 Dec 2025 11:57AM UTC coverage: 75.251%. First build
20027296451

Pull #512

github

dissoupov
Cache: delete multiple keys
Pull Request #512: Cache: delete multiple keys

20 of 27 new or added lines in 3 files covered. (74.07%)

5318 of 7067 relevant lines covered (75.25%)

11.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.56
/pkg/cache/proxy.go
1
package cache
2

3
import (
4
        "context"
5
        "path"
6
        "time"
7
)
8

9
type proxyProv struct {
10
        prefix string
11
        prov   Provider
12
}
13

14
// NewProxyProvider returns proxy provider
15
func NewProxyProvider(prefix string, prov Provider) Provider {
4✔
16
        p := &proxyProv{
4✔
17
                prefix: prefix,
4✔
18
                prov:   prov,
4✔
19
        }
4✔
20

4✔
21
        return p
4✔
22
}
4✔
23

24
func (p *proxyProv) keyName(key string) string {
186✔
25
        return path.Join(p.prefix, key)
186✔
26
}
186✔
27

28
// Close closes the client, releasing any open resources.
29
// It is rare to Close a Client, as the Client is meant to be long-lived and shared between many goroutines.
30
func (p *proxyProv) Close() error {
1✔
31
        // this method does nothing as the parent must be closed safely
1✔
32
        return nil
1✔
33
}
1✔
34

35
// IsLocal returns true, if cache is local
36
func (p *proxyProv) IsLocal() bool {
1✔
37
        return p.prov.IsLocal()
1✔
38
}
1✔
39

40
// Set data
41
func (p *proxyProv) Set(ctx context.Context, key string, v any, ttl time.Duration) error {
64✔
42
        return p.prov.Set(ctx, p.keyName(key), v, ttl)
64✔
43
}
64✔
44

45
// Get data
46
func (p *proxyProv) Get(ctx context.Context, key string, v any) error {
73✔
47
        return p.prov.Get(ctx, p.keyName(key), v)
73✔
48
}
73✔
49

50
// Delete data
51
func (p *proxyProv) Delete(ctx context.Context, keys ...string) error {
48✔
52
        if len(keys) == 0 {
48✔
NEW
53
                return nil
×
NEW
54
        }
×
55
        pkeys := make([]string, 0, len(keys))
48✔
56
        for _, key := range keys {
96✔
57
                pkeys = append(pkeys, p.keyName(key))
48✔
58
        }
48✔
59
        return p.prov.Delete(ctx, pkeys...)
48✔
60
}
61

62
// CleanExpired data
63
func (p *proxyProv) CleanExpired(ctx context.Context) {
6✔
64
        p.prov.CleanExpired(ctx)
6✔
65
}
6✔
66

67
// Keys returns list of keys.
68
// This method should be used mostly for testing, as in prod many keys maybe returned
69
func (p *proxyProv) Keys(ctx context.Context, pattern string) ([]string, error) {
1✔
70
        return p.prov.Keys(ctx, p.keyName(pattern))
1✔
71
}
1✔
72

73
// Subscribe subscribes to channel
74
func (p *proxyProv) Subscribe(ctx context.Context, channel string) Subscription {
12✔
75
        return p.prov.Subscribe(ctx, channel)
12✔
76
}
12✔
77

78
// Publish publishes message to channel
79
func (p *proxyProv) Publish(ctx context.Context, channel, message string) error {
4✔
80
        return p.prov.Publish(ctx, channel, message)
4✔
81
}
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc