-
-
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
ff915e7
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
457
ops/sec (±0.82%
)424
ops/sec (±2.32%
)0.93
infer All
8788
ops/sec (±1.19%
)8956
ops/sec (±2.03%
)1.02
denormalizeLong
276
ops/sec (±1.77%
)287
ops/sec (±2.10%
)1.04
denormalizeLong donotcache
737
ops/sec (±0.57%
)747
ops/sec (±0.48%
)1.01
denormalizeShort donotcache 500x
1264
ops/sec (±0.14%
)1315
ops/sec (±0.43%
)1.04
denormalizeShort 500x
882
ops/sec (±1.24%
)911
ops/sec (±0.50%
)1.03
denormalizeLong with mixin Entity
277
ops/sec (±0.48%
)274
ops/sec (±0.29%
)0.99
denormalizeLong withCache
5851
ops/sec (±0.20%
)6038
ops/sec (±0.26%
)1.03
denormalizeLongAndShort withEntityCacheOnly
1473
ops/sec (±0.37%
)1518
ops/sec (±0.49%
)1.03
denormalizeLong All withCache
7125
ops/sec (±0.16%
)7102
ops/sec (±0.29%
)1.00
denormalizeLong Query-sorted withCache
6969
ops/sec (±0.22%
)7095
ops/sec (±0.31%
)1.02
getResponse
5539
ops/sec (±1.04%
)5833
ops/sec (±1.47%
)1.05
getResponse (null)
2911710
ops/sec (±0.14%
)2895891
ops/sec (±0.44%
)0.99
getResponse (clear cache)
261
ops/sec (±0.55%
)266
ops/sec (±0.59%
)1.02
getSmallResponse
2032
ops/sec (±0.15%
)2144
ops/sec (±1.22%
)1.06
getSmallInferredResponse
1781
ops/sec (±0.45%
)1790
ops/sec (±0.53%
)1.01
getResponse Query-sorted
685
ops/sec (±1.12%
)675
ops/sec (±1.49%
)0.99
getResponse Collection
5159
ops/sec (±1.20%
)5012
ops/sec (±0.95%
)0.97
setLong
452
ops/sec (±0.27%
)424
ops/sec (±2.79%
)0.94
setLongWithMerge
183
ops/sec (±0.24%
)188
ops/sec (±0.39%
)1.03
setLongWithSimpleMerge
197
ops/sec (±0.27%
)202
ops/sec (±0.53%
)1.03
This comment was automatically generated by workflow using github-action-benchmark.