-
Notifications
You must be signed in to change notification settings - Fork 0
/
options_gen.go
173 lines (159 loc) · 5.97 KB
/
options_gen.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// Code generated by troptgen. DO NOT EDIT.
package trcache
import "time"
// WithName sets the cache name.
func WithName[K comparable, V any](name string) RootOption {
const optionName = "github.com/rrgmc/trcache/NameOptions.Name"
const optionHash = uint64(0x3981bf0acdb00351)
return RootOptionFunc(func(o any) bool {
switch opt := o.(type) {
case NameOptions[K, V]:
opt.OptName(name)
return true
}
return false
}, optionName, optionHash)
}
// WithMetrics sets the [Metrics] instance to call for metrics.
func WithMetrics[K comparable, V any](metrics Metrics, name string) RootOption {
const optionName = "github.com/rrgmc/trcache/MetricsOptions.Metrics"
const optionHash = uint64(0xca3281438b1cece3)
return RootOptionFunc(func(o any) bool {
switch opt := o.(type) {
case MetricsOptions[K, V]:
opt.OptMetrics(metrics, name)
return true
}
return false
}, optionName, optionHash)
}
// WithCallDefaultDeleteOptions sets the default options to be appended to all [Cache.Delete] calls.
func WithCallDefaultDeleteOptions[K comparable, V any](options ...DeleteOption) RootOption {
const optionName = "github.com/rrgmc/trcache/CallDefaultOptions.CallDefaultDeleteOptions"
const optionHash = uint64(0xac15a04b8e756920)
return RootOptionFunc(func(o any) bool {
switch opt := o.(type) {
case CallDefaultOptions[K, V]:
opt.OptCallDefaultDeleteOptions(options...)
return true
}
return false
}, optionName, optionHash)
}
// WithCallDefaultGetOptions sets the default options to be appended to all [Cache.Get] calls.
func WithCallDefaultGetOptions[K comparable, V any](options ...GetOption) RootOption {
const optionName = "github.com/rrgmc/trcache/CallDefaultOptions.CallDefaultGetOptions"
const optionHash = uint64(0xd1b76ecec1713d15)
return RootOptionFunc(func(o any) bool {
switch opt := o.(type) {
case CallDefaultOptions[K, V]:
opt.OptCallDefaultGetOptions(options...)
return true
}
return false
}, optionName, optionHash)
}
// WithCallDefaultSetOptions sets the default options to be appended to all [Cache.Set] calls.
func WithCallDefaultSetOptions[K comparable, V any](options ...SetOption) RootOption {
const optionName = "github.com/rrgmc/trcache/CallDefaultOptions.CallDefaultSetOptions"
const optionHash = uint64(0x882e09a1ba1e6b99)
return RootOptionFunc(func(o any) bool {
switch opt := o.(type) {
case CallDefaultOptions[K, V]:
opt.OptCallDefaultSetOptions(options...)
return true
}
return false
}, optionName, optionHash)
}
// WithCallDefaultRefreshOptions sets the default options to be appended to all [RefreshCache.GetOrRefresh] calls.
func WithCallDefaultRefreshOptions[K comparable, V any](options ...RefreshOption) RootOption {
const optionName = "github.com/rrgmc/trcache/CallDefaultRefreshOptions.CallDefaultRefreshOptions"
const optionHash = uint64(0x8e5d66b3fceb8305)
return RootOptionFunc(func(o any) bool {
switch opt := o.(type) {
case CallDefaultRefreshOptions[K, V]:
opt.OptCallDefaultRefreshOptions(options...)
return true
}
return false
}, optionName, optionHash)
}
// WithSetDuration sets the cache duration (TTL) to be used for this set call instead of the default.
func WithSetDuration[K comparable, V any](duration time.Duration) SetOption {
const optionName = "github.com/rrgmc/trcache/SetOptions.Duration"
const optionHash = uint64(0xa4a144e805884037)
return SetOptionFunc(func(o any) bool {
switch opt := o.(type) {
case SetOptions[K, V]:
opt.OptDuration(duration)
return true
}
return false
}, optionName, optionHash)
}
// WithRefreshData sets a custom data to be sent to the refresh function.
func WithRefreshData[K comparable, V any](data interface{}) RefreshOption {
const optionName = "github.com/rrgmc/trcache/RefreshOptions.Data"
const optionHash = uint64(0x7b01c4b7727d2dfe)
return RefreshOptionFunc(func(o any) bool {
switch opt := o.(type) {
case RefreshOptions[K, V]:
opt.OptData(data)
return true
}
return false
}, optionName, optionHash)
}
// WithRefreshFunc sets the refresh function for this call, possibly overriding a default one.
func WithRefreshFunc[K comparable, V any](refreshFunc CacheRefreshFunc[K, V]) RefreshOption {
const optionName = "github.com/rrgmc/trcache/RefreshOptions.Func"
const optionHash = uint64(0x68fd6cb76815eb74)
return RefreshOptionFunc(func(o any) bool {
switch opt := o.(type) {
case RefreshOptions[K, V]:
opt.OptFunc(refreshFunc)
return true
}
return false
}, optionName, optionHash)
}
// WithRefreshGetOptions sets the options to be appended to all [Cache.Get] calls inside the refresh function.
func WithRefreshGetOptions[K comparable, V any](options ...GetOption) RefreshOption {
const optionName = "github.com/rrgmc/trcache/RefreshOptions.GetOptions"
const optionHash = uint64(0x25f3602608161b58)
return RefreshOptionFunc(func(o any) bool {
switch opt := o.(type) {
case RefreshOptions[K, V]:
opt.OptGetOptions(options...)
return true
}
return false
}, optionName, optionHash)
}
// WithRefreshSetOptions sets the options to be appended to all [Cache.Set] calls inside the refresh function.
func WithRefreshSetOptions[K comparable, V any](options ...SetOption) RefreshOption {
const optionName = "github.com/rrgmc/trcache/RefreshOptions.SetOptions"
const optionHash = uint64(0x5d79af8603efd9cc)
return RefreshOptionFunc(func(o any) bool {
switch opt := o.(type) {
case RefreshOptions[K, V]:
opt.OptSetOptions(options...)
return true
}
return false
}, optionName, optionHash)
}
// WithDefaultRefreshFunc sets the default refresh function to be used for [RefreshCache.GetOrRefresh].
func WithDefaultRefreshFunc[K comparable, V any](refreshFunc CacheRefreshFunc[K, V]) RootOption {
const optionName = "github.com/rrgmc/trcache/DefaultRefreshOptions.DefaultRefreshFunc"
const optionHash = uint64(0xb6fb96f222d714cb)
return RootOptionFunc(func(o any) bool {
switch opt := o.(type) {
case DefaultRefreshOptions[K, V]:
opt.OptDefaultRefreshFunc(refreshFunc)
return true
}
return false
}, optionName, optionHash)
}