-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Resurrected the STATIC flag reason. Documented the caching stra…
…tegy. (#224) Resurrected the STATIC flag reason. Documented the caching strategy. Signed-off-by: Skye Gill <gill.skye95@gmail.com> Co-authored-by: Todd Baert <toddbaert@gmail.com>
- Loading branch information
Showing
4 changed files
with
46 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
### Caching | ||
|
||
`flagd` has a caching strategy implementable by providers that support server-to-client streaming. | ||
|
||
#### Cacheable flags | ||
|
||
`flagd` sets the `reason` of a flag evaluation as `STATIC` when no targeting rules are configured for the flag. A client can safely store the result of a static evaluation in its cache indefinitely (until the configuration of the flag changes, see [cache invalidation](#cache-invalidation)). | ||
|
||
Put simply in pseudocode: | ||
|
||
``` | ||
if reason == "STATIC" { | ||
isFlagCacheable = true | ||
} | ||
``` | ||
|
||
#### Cache invalidation | ||
|
||
`flagd` emits events to the server-to-client stream, among these is the `configuration_change` event. The structure of this event is as such: | ||
|
||
``` | ||
{ | ||
"type": "delete", // ENUM:["delete","write","update"] | ||
"source": "/flag-configuration.json", // the source of the flag configuration | ||
"flagKey": "foo" | ||
} | ||
``` | ||
|
||
A client should bust the cache of any flag found in a `configuration_change` event to prevent stale data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ const ( | |
DefaultReason = "DEFAULT" | ||
UnknownReason = "UNKNOWN" | ||
ErrorReason = "ERROR" | ||
StaticReason = "STATIC" | ||
) |