Skip to content

Commit ae42e85

Browse files
committed
chore: add doc
Signed-off-by: nikolay <n.atanasow94@gmail.com>
1 parent eff9c7a commit ae42e85

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

packages/relay/src/lib/decorators/cache.decorator.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ interface CacheOptions {
2525
ttl?: number,
2626
}
2727

28+
/**
29+
* Skip single params in the following format
30+
*
31+
* [{
32+
* index: '0',
33+
* value: 'pending|safe'
34+
* }]
35+
*
36+
* @param args
37+
* @param params
38+
*/
2839
const shouldSkipCachingForSingleParams = (args: any, params: any = []) => {
2940
for (const item of params) {
3041
const values = item.value.split('|');
@@ -36,6 +47,21 @@ const shouldSkipCachingForSingleParams = (args: any, params: any = []) => {
3647
return false;
3748
};
3849

50+
/**
51+
* Skip named params in the following format
52+
*
53+
* [{
54+
* index: '0',
55+
* fields: [{
56+
* name: 'fromBlock', value: 'pending|safe'
57+
* }, {
58+
* name: 'toBlock', value: 'safe|finalized'
59+
* }],
60+
* }]
61+
*
62+
* @param args
63+
* @param params
64+
*/
3965
const shouldSkipCachingForNamedParams = (args: any, params: any = []) => {
4066
for (const item of params) {
4167
const input = args[item.index];
@@ -54,6 +80,12 @@ const shouldSkipCachingForNamedParams = (args: any, params: any = []) => {
5480
return false;
5581
};
5682

83+
/**
84+
* Generate cache key by method name and passed arguments
85+
*
86+
* @param methodName
87+
* @param args
88+
*/
5789
const generateCacheKey = (methodName: string, args: any) => {
5890
let cacheKey: string = methodName;
5991
for (const [, value] of Object.entries(args)) {
@@ -72,6 +104,11 @@ const generateCacheKey = (methodName: string, args: any) => {
72104
return cacheKey;
73105
};
74106

107+
/**
108+
* Extract the RequestDetails field from the arguments
109+
*
110+
* @param args
111+
*/
75112
const extractRequestDetails = (args: any): RequestDetails => {
76113
let requestId, ipAddress, connectionId: string = '';
77114
for (const [, value] of Object.entries(args)) {

0 commit comments

Comments
 (0)