@@ -11,7 +11,7 @@ export class RedisCacheProvider implements CacheProvider {
1111 }
1212
1313 async get ( key : string ) {
14- const entryJson = await this . redis . get ( formatQueryKey ( key ) )
14+ const entryJson = await this . redis . get ( makeQueryKey ( key ) )
1515
1616 if ( ! entryJson ) {
1717 return undefined
@@ -22,28 +22,27 @@ export class RedisCacheProvider implements CacheProvider {
2222
2323 async set ( key : string , entry : CacheEntry ) {
2424 const multi = this . redis . multi ( )
25- const formattedKey = formatQueryKey ( key )
25+ const queryKey = makeQueryKey ( key )
2626
27- multi . set ( formattedKey , superjson . stringify ( entry ) )
27+ multi . set ( queryKey , superjson . stringify ( entry ) )
2828
2929 const totalTtl = getTotalTtl ( entry )
3030
3131 if ( totalTtl > 0 ) {
32- multi . expire ( formattedKey , totalTtl )
32+ multi . expire ( queryKey , totalTtl )
3333 }
3434
3535 if ( entry . options . tags ) {
3636 for ( const tag of entry . options . tags ) {
37- const formattedTagKey = formatTagKey ( tag )
37+ const tagKey = makeTagKey ( tag )
3838
39- multi . sadd ( formattedTagKey , formattedKey )
39+ multi . sadd ( tagKey , queryKey )
4040
4141 if ( totalTtl > 0 ) {
42- multi . expire ( formattedTagKey , totalTtl , 'GT' )
43- multi . expire ( formattedTagKey , totalTtl , 'NX' )
44- }
45- else {
46- multi . persist ( formattedTagKey )
42+ multi . expire ( tagKey , totalTtl , 'GT' )
43+ multi . expire ( tagKey , totalTtl , 'NX' )
44+ } else {
45+ multi . persist ( tagKey )
4746 }
4847 }
4948 }
@@ -56,7 +55,7 @@ export class RedisCacheProvider implements CacheProvider {
5655 await Promise . all (
5756 options . tags . map ( tag => {
5857 return new Promise ( ( resolve , reject ) => {
59- const stream = this . redis . sscanStream ( formatTagKey ( tag ) , {
58+ const stream = this . redis . sscanStream ( makeTagKey ( tag ) , {
6059 count : 100 ,
6160 } )
6261
@@ -97,10 +96,10 @@ export type RedisCacheProviderOptions = {
9796 url : string
9897}
9998
100- function formatQueryKey ( key : string ) {
99+ function makeQueryKey ( key : string ) {
101100 return `zenstack:cache:query:${ key } `
102101}
103102
104- function formatTagKey ( key : string ) {
103+ function makeTagKey ( key : string ) {
105104 return `zenstack:cache:tag:${ key } `
106105}
0 commit comments