Bring back fact CAS
- Dominant language
- Go
- Stars
- 337
- Forks
- 58
- PR merge metrics
- No merged PRs in 30d
Description
Previously we had a fact [compare and [set]](https://en.wikipedia.org/wiki/Compare-and-swap). Basically:
``` Go
func SetFactConditional(id Id, fact Fact, pattern Pattern) (Id,bool,error)
```
Get the fact with the given id. If the fact matches the pattern, delete that fact and assert the given fact at the given id (and return `true`). If the fact doesn't match the given pattern, do nothing (and return `false`).
The implementation at this level is -- I think -- still straightforward. Lock the index, get the fact, pattern match, delete the old match, write the new fact, unlock the index. The underlying `Storage` can optionally protest using its standard mechanism (if any) that checks for changed data (either specifically or location-wide) (e.g., using DynamoDB conditional writes that check a location timestamp or sequence number or whatever).
Contributor guide
Assessment
This issue has not been assessed yet.