Skip to content

Commit f96cafd

Browse files
committed
chore: working
1 parent 375468d commit f96cafd

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/paths.d.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff 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.

tests/redis.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {random} from 'lodash';
22
import {type RedisStore, redisStore} from 'cache-manager-ioredis-yet';
3-
import {cachedFunction, getOrInitializeCache, resetCache} from '../src';
3+
import {cachedFunction, getOrInitializeCache} from '../src';
44

55
type Person = {
66
id?: string;
@@ -13,20 +13,23 @@ type Person = {
1313
};
1414

1515
async function createPerson(person: Person) {
16-
person.id = random(0, 100_000).toString();
1716
console.log('Person created!!!!!');
1817
return person;
1918
}
2019

2120
const cache = await getOrInitializeCache<RedisStore>({
22-
store: await redisStore(),
21+
store: await redisStore({
22+
host: 'localhost',
23+
port: 6379,
24+
}),
2325
});
2426
const cachedCreatePerson = cachedFunction(createPerson, {
25-
selector: '0.id',
27+
selector: '0.name',
2628
ttl: 10_000,
2729
});
2830

2931
const 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
});
3740
console.log(person.id, person.name);
38-

0 commit comments

Comments
 (0)