File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,12 @@ export type AnyFunction = (...arguments_: any[]) => any;
1919 * Represents the type for generating paths of a given object.
2020 *
2121 * @template T - The type of the object.
22- */
23- type Paths < T > = T extends Record < string , unknown > ? { [ K in keyof T ] :
24- `${Exclude < K , symbol > } ${'' | `.${Paths < T [ K ] > } `} `
25- } [ keyof T ] : never ;
22+ * type Paths<T> = T extends Record<string, unknown> ? {[K in keyof T]:
23+ * `${Exclude<K, symbol>}${'' | `.${Paths<T[K]>}`}`
24+ * }[keyof T] : never;
25+ */
26+ // TODO: Implement the Paths type.
27+ export type Paths < T > = string ;
2628
2729/**
2830 * Represents the paths of the arguments of a given function type.
Original file line number Diff line number Diff line change 11import { random } from 'lodash' ;
22import { type RedisStore , redisStore } from 'cache-manager-ioredis-yet' ;
3- import { cachedFunction , getOrInitializeCache , resetCache } from '../src' ;
3+ import { cachedFunction , getOrInitializeCache } from '../src' ;
44
55type Person = {
66 id ?: string ;
@@ -13,20 +13,23 @@ type Person = {
1313} ;
1414
1515async function createPerson ( person : Person ) {
16- person . id = random ( 0 , 100_000 ) . toString ( ) ;
1716 console . log ( 'Person created!!!!!' ) ;
1817 return person ;
1918}
2019
2120const cache = await getOrInitializeCache < RedisStore > ( {
22- store : await redisStore ( ) ,
21+ store : await redisStore ( {
22+ host : 'localhost' ,
23+ port : 6379 ,
24+ } ) ,
2325} ) ;
2426const cachedCreatePerson = cachedFunction ( createPerson , {
25- selector : '0.id ' ,
27+ selector : '0.name ' ,
2628 ttl : 10_000 ,
2729} ) ;
2830
2931const person = await cachedCreatePerson ( {
32+ id : random ( 0 , 100_000 ) . toString ( ) ,
3033 name : 'Tomer Horowitz' ,
3134 age : 23 ,
3235 address : {
@@ -35,4 +38,3 @@ const person = await cachedCreatePerson({
3538 } ,
3639} ) ;
3740console . log ( person . id , person . name ) ;
38-
You can’t perform that action at this time.
0 commit comments