-
-
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
e795722
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
452
ops/sec (±2.02%
)457
ops/sec (±2.18%
)1.01
infer All
9578
ops/sec (±1.70%
)9619
ops/sec (±1.44%
)1.00
denormalizeLong
318
ops/sec (±2.52%
)321
ops/sec (±2.46%
)1.01
denormalizeLong donotcache
859
ops/sec (±0.59%
)873
ops/sec (±0.44%
)1.02
denormalizeShort donotcache 500x
1363
ops/sec (±0.43%
)1365
ops/sec (±0.30%
)1.00
denormalizeShort 500x
962
ops/sec (±0.37%
)936
ops/sec (±0.37%
)0.97
denormalizeLong with mixin Entity
274
ops/sec (±0.33%
)289
ops/sec (±0.35%
)1.05
denormalizeLong withCache
7256
ops/sec (±0.29%
)7145
ops/sec (±0.34%
)0.98
denormalizeLongAndShort withEntityCacheOnly
1621
ops/sec (±0.31%
)1608
ops/sec (±0.45%
)0.99
denormalizeLong All withCache
6092
ops/sec (±0.24%
)5974
ops/sec (±0.68%
)0.98
denormalizeLong Query-sorted withCache
6463
ops/sec (±0.28%
)6353
ops/sec (±0.25%
)0.98
getResponse
5008
ops/sec (±0.78%
)5140
ops/sec (±1.32%
)1.03
getResponse (null)
2883926
ops/sec (±0.22%
)3116142
ops/sec (±0.26%
)1.08
getResponse (clear cache)
291
ops/sec (±0.53%
)300
ops/sec (±0.27%
)1.03
getSmallResponse
2253
ops/sec (±0.41%
)2300
ops/sec (±0.30%
)1.02
getSmallInferredResponse
1805
ops/sec (±0.24%
)1790
ops/sec (±0.17%
)0.99
getResponse Query-sorted
697
ops/sec (±1.51%
)697
ops/sec (±1.64%
)1
getResponse Collection
4831
ops/sec (±0.63%
)4979
ops/sec (±1.00%
)1.03
setLong
437
ops/sec (±2.04%
)454
ops/sec (±1.98%
)1.04
setLongWithMerge
191
ops/sec (±0.96%
)193
ops/sec (±0.66%
)1.01
setLongWithSimpleMerge
201
ops/sec (±0.34%
)206
ops/sec (±0.34%
)1.02
This comment was automatically generated by workflow using github-action-benchmark.