Skip to content

Commit dff7384

Browse files
committed
📖 Add a design for cache options configuration
1 parent c52016d commit dff7384

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed

designs/cache_options.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
Cache Options
2+
===================
3+
4+
This document describes how we imagine the cache options to look like in
5+
the future.
6+
7+
## Goals
8+
9+
* Align everyone on what settings on the cache we want to support and
10+
their configuration surface
11+
* Ensure that we support both complicated cache setups and provide an
12+
intuitive configuration UX
13+
14+
## Non-Goals
15+
16+
* Line out how the actual implementation of the cache itself will look like.
17+
The assumption is that the most granular level we will end up with is
18+
"per object multiple namespaces with distinct selectors" and that this
19+
can be implemented using a "meta cache" that delegates per object and by
20+
extending the current multi-namespace cache
21+
* Outline any kind of timeline for when these settings will be implemented.
22+
Implementation will happen gradually over time whenever someone steps up
23+
to do the actual work
24+
25+
## Proposal
26+
27+
28+
```
29+
type CacheSetting struct {
30+
// LabelSelector specifies a label selector. A nil value allows to
31+
// default this.
32+
LabelSelector labels.Selector
33+
34+
// FieldSelector specifics a field selector. A nil value allows to
35+
// default this.
36+
FieldSelector fields.Selector
37+
38+
// Transform specifies a transform func. A nil value allows to default
39+
// this.
40+
Transform toolscache.TransformFunc
41+
42+
// UnsafeDisableDeepCopy specifies if List and Get requests against the
43+
// cache should not DeepCopy. A nil value allows to default this.
44+
UnsafeDisableDeepCopy *bool
45+
}
46+
47+
48+
type ByObject struct {
49+
// Namespaces maps a namespace name to cache setting. If set, only the
50+
// namespaces in this map will be cached.
51+
//
52+
// A nil value in this map means "fall through to the ByObject CacheSetting"
53+
//
54+
// An empty value in this map means "No Selectors".
55+
//
56+
// It is possible to have specific CacheSettings for just some namespaces
57+
// but cache all namespaces by using the empty string as map key for
58+
// "all namespaces". This wil then include all namespaces that do not have
59+
// a more specific setting.
60+
//
61+
// A nil map allows to default this to the caches DefaultNamespaces setting.
62+
// An empty map prevents this.
63+
Namespaces map[string]*CacheSetting
64+
65+
// CacheSettings will be used if Namespaces is empty or for entries in
66+
// Namespaces that have a nil value.
67+
//
68+
// If nil, this will be defaulted to the caches DefaultLabelSelector,
69+
// DefaultFieldSelector and DefaultTransform.
70+
CacheSettings *CacheSetting
71+
}
72+
73+
type Options struct {
74+
// ByObject specifies per-object cache settings. If unset for a given
75+
// object, this will fall through to Default* settings.
76+
ByObject map[client.Object]*ByObject
77+
78+
// DefaultNamespaces maps namespace names to cache settings. If set, it
79+
// will be usd for all objects that have a nil Namespaces setting.
80+
//
81+
// It is possible to have specific CacheSettings for just some namespaces
82+
// but cache all namespaces by using the empty string as map key for
83+
// "all namespaces". This wil then include all namespaces that do not have
84+
// a more specific setting.
85+
//
86+
// If CacheSetting is nil, DefaultLabelSelector, DefaultFieldSelector
87+
// and DefaultTransform will be used if set.
88+
DefaultNamespaces map[string]*CacheSetting
89+
90+
// DefaultLabelSelector is the label selector that will be used as
91+
// the default field label selector for everything that doesn't
92+
// have one configured.
93+
DefaultLabelSelector labels.Selector
94+
95+
// DefaultFieldSelector is the field selector that will be used as
96+
// the default field selector for everything that doesn't have
97+
// one configured.
98+
DefaultFieldSelector fields.Selector
99+
100+
// DefaultUnsafeDisableDeepCopy is the default for UnsafeDisableDeepCopy
101+
// for everything that doesn't specify this.
102+
DefaultUnsafeDisableDeepCopy *bool
103+
}
104+
```

0 commit comments

Comments
 (0)