-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Use Querable schemas in useCache()
- Loading branch information
Showing
15 changed files
with
108 additions
and
67 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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
| Schema | Description | Data Type | Mutable | Has A | | ||
| ---------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | --------------- | | ||
| [Entity](/rest/api/Entity) | single _unique_ object | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | ✅ | | | ||
| [Object](/rest/api/Object) | statically known keys | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | 🛑 | | | ||
| [Array](/rest/api/Array) | lists of any size | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) | 🛑 | | | ||
| [Values](/rest/api/Values) | maps of any size | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | 🛑 | | | ||
| [All](/rest/api/All) | list of all entities of a kind | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) | 🛑 | Entity | | ||
| [Collection](/rest/api/Collection) | enables adding new items | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) or [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) | ✅ | Array or Values | | ||
| [Union](/rest/api/Union) | one of many different types (`A \| B`) | Polymorphic [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | ✅ | Entity | | ||
| [Invalidate](/rest/api/Invalidate) | [remove an entity](../concepts/expiry-policy.md#any-endpoint-with-an-entity) | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | ✅ | Entity | | ||
| Schema | Description | Data Type | Mutable | Queryable | Of A | | ||
| ---------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | --------- | --------- | | ||
| [Entity](/rest/api/Entity) | single _unique_ object | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | ✅ | ✅ | | | ||
| [Object](/rest/api/Object) | statically known keys | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | 🛑 | 🛑 | | | ||
| [Array](/rest/api/Array) | lists of any size | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) | 🛑 | 🛑 | | | ||
| [Values](/rest/api/Values) | maps of any size | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | 🛑 | 🛑 | | | ||
| [All](/rest/api/All) | list of all entities of a kind | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) | 🛑 | ✅ | | | ||
| [Collection](/rest/api/Collection) | enables adding new items | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) or [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) | ✅ | ✅ | | | ||
| [Query](/rest/api/Query) | memoized custom transforms | any | 🛑 | ✅ | Queryable | | ||
| [Union](/rest/api/Union) | one of many different types (`A \| B`) | Polymorphic [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | ✅ | ✅ | Entity | | ||
| [Invalidate](/rest/api/Invalidate) | [remove an entity](../concepts/expiry-policy.md#any-endpoint-with-an-entity) | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | ✅ | 🛑 | Entity | |
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,4 @@ | ||
/** Attempts to infer reasonable input type to construct an Entity */ | ||
export type EntityFields<U> = { | ||
readonly [K in keyof U]?: U[K]; | ||
}; |
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
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** Attempts to infer reasonable input type to construct an Entity */ | ||
export type EntityFields<U> = { | ||
readonly [K in keyof U as U[K] extends (...args: any) => any ? never | ||
: K]?: U[K]; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** Attempts to infer reasonable input type to construct an Entity */ | ||
export type EntityFields<U> = { | ||
readonly [K in keyof U as U[K] extends (...args: any) => any ? never | ||
: K]?: U[K]; | ||
}; |
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
b9c5b7b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
normalizeLong
416
ops/sec (±1.65%
)443
ops/sec (±0.28%
)1.06
infer All
8952
ops/sec (±1.55%
)8574
ops/sec (±2.55%
)0.96
denormalizeLong
268
ops/sec (±1.85%
)257
ops/sec (±2.08%
)0.96
denormalizeLong donotcache
715
ops/sec (±0.59%
)709
ops/sec (±0.50%
)0.99
denormalizeShort donotcache 500x
1267
ops/sec (±0.39%
)1246
ops/sec (±0.17%
)0.98
denormalizeShort 500x
871
ops/sec (±0.40%
)881
ops/sec (±0.14%
)1.01
denormalizeLong with mixin Entity
265
ops/sec (±1.31%
)264
ops/sec (±0.26%
)1.00
denormalizeLong withCache
5834
ops/sec (±0.13%
)5912
ops/sec (±0.15%
)1.01
denormalizeLongAndShort withEntityCacheOnly
1459
ops/sec (±0.19%
)1421
ops/sec (±1.23%
)0.97
denormalizeLong All withCache
7211
ops/sec (±0.37%
)6956
ops/sec (±0.28%
)0.96
denormalizeLong Query-sorted withCache
6988
ops/sec (±0.39%
)6819
ops/sec (±0.16%
)0.98
getResponse
5410
ops/sec (±1.33%
)5510
ops/sec (±1.14%
)1.02
getResponse (null)
2802329
ops/sec (±1.00%
)2788300
ops/sec (±0.29%
)0.99
getResponse (clear cache)
244
ops/sec (±0.70%
)252
ops/sec (±0.55%
)1.03
getSmallResponse
2012
ops/sec (±0.24%
)2024
ops/sec (±0.42%
)1.01
getSmallInferredResponse
1765
ops/sec (±0.32%
)1786
ops/sec (±0.15%
)1.01
getResponse Query-sorted
641
ops/sec (±1.38%
)627
ops/sec (±1.81%
)0.98
getResponse Collection
5141
ops/sec (±1.02%
)4768
ops/sec (±0.82%
)0.93
setLong
428
ops/sec (±0.56%
)429
ops/sec (±0.87%
)1.00
setLongWithMerge
173
ops/sec (±0.49%
)172
ops/sec (±0.50%
)0.99
setLongWithSimpleMerge
188
ops/sec (±0.58%
)184
ops/sec (±0.85%
)0.98
This comment was automatically generated by workflow using github-action-benchmark.