@@ -25,6 +25,17 @@ interface CacheOptions {
25
25
ttl ?: number ,
26
26
}
27
27
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
+ */
28
39
const shouldSkipCachingForSingleParams = ( args : any , params : any = [ ] ) => {
29
40
for ( const item of params ) {
30
41
const values = item . value . split ( '|' ) ;
@@ -36,6 +47,21 @@ const shouldSkipCachingForSingleParams = (args: any, params: any = []) => {
36
47
return false ;
37
48
} ;
38
49
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
+ */
39
65
const shouldSkipCachingForNamedParams = ( args : any , params : any = [ ] ) => {
40
66
for ( const item of params ) {
41
67
const input = args [ item . index ] ;
@@ -54,6 +80,12 @@ const shouldSkipCachingForNamedParams = (args: any, params: any = []) => {
54
80
return false ;
55
81
} ;
56
82
83
+ /**
84
+ * Generate cache key by method name and passed arguments
85
+ *
86
+ * @param methodName
87
+ * @param args
88
+ */
57
89
const generateCacheKey = ( methodName : string , args : any ) => {
58
90
let cacheKey : string = methodName ;
59
91
for ( const [ , value ] of Object . entries ( args ) ) {
@@ -72,6 +104,11 @@ const generateCacheKey = (methodName: string, args: any) => {
72
104
return cacheKey ;
73
105
} ;
74
106
107
+ /**
108
+ * Extract the RequestDetails field from the arguments
109
+ *
110
+ * @param args
111
+ */
75
112
const extractRequestDetails = ( args : any ) : RequestDetails => {
76
113
let requestId , ipAddress , connectionId : string = '' ;
77
114
for ( const [ , value ] of Object . entries ( args ) ) {
0 commit comments