-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix asset likes repository integration
- Loading branch information
1 parent
8854e68
commit 5375b1a
Showing
14 changed files
with
105 additions
and
171 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,45 @@ | ||
// import { RedisCacheService } from '@multiversx/sdk-nestjs'; | ||
// import { Inject, Injectable, Logger } from '@nestjs/common'; | ||
// import { isNil } from '@nestjs/common/utils/shared.utils'; | ||
// import Redis from 'ioredis'; | ||
// export const REDIS_CLIENT_TOKEN = 'REDIS_CLIENT_TOKEN'; | ||
// @Injectable() | ||
// export class LocalRedisCacheService { | ||
// constructor( | ||
// private readonly logger: Logger, | ||
// private readonly redisCacheService: RedisCacheService, | ||
// @Inject('REDIS_CLIENT_TOKEN') private readonly redis: Redis, | ||
// ) {} | ||
import { RedisCacheService } from '@multiversx/sdk-nestjs'; | ||
import { Injectable, Logger } from '@nestjs/common'; | ||
import { isNil } from '@nestjs/common/utils/shared.utils'; | ||
export const REDIS_CLIENT_TOKEN = 'REDIS_CLIENT_TOKEN'; | ||
@Injectable() | ||
export class LocalRedisCacheService { | ||
constructor( | ||
private readonly logger: Logger, | ||
private readonly redisCacheService: RedisCacheService, | ||
) {} | ||
|
||
// async getOrSetWithDifferentTtl( | ||
// key: string, | ||
// createValueFunc: () => any, | ||
// ): Promise<any> { | ||
// const cachedData = await this.redisCacheService.get(key); | ||
// if (!isNil(cachedData)) { | ||
// return cachedData; | ||
// } | ||
// const value = await this.buildInternalCreateValueFunc(key, createValueFunc); | ||
// await this.redisCacheService.set(key, value, value.ttl); | ||
async getOrSetWithDifferentTtl( | ||
key: string, | ||
createValueFunc: () => any, | ||
): Promise<any> { | ||
const cachedData = await this.redisCacheService.get(key); | ||
if (!isNil(cachedData)) { | ||
return cachedData; | ||
} | ||
const value = await this.buildInternalCreateValueFunc(key, createValueFunc); | ||
await this.redisCacheService.set(key, value, value.ttl); | ||
|
||
// return value; | ||
// } | ||
return value; | ||
} | ||
|
||
// private async buildInternalCreateValueFunc( | ||
// key: string, | ||
// createValueFunc: () => any, | ||
// ): Promise<any> { | ||
// try { | ||
// let data = createValueFunc(); | ||
// if (data instanceof Promise) { | ||
// data = await data; | ||
// } | ||
// return data; | ||
// } catch (err) { | ||
// this.logger.error(`An error occurred while trying to load value.`, { | ||
// path: 'redis-cache.service.createValueFunc', | ||
// exception: err, | ||
// key, | ||
// }); | ||
// return null; | ||
// } | ||
// } | ||
// } | ||
private async buildInternalCreateValueFunc( | ||
key: string, | ||
createValueFunc: () => any, | ||
): Promise<any> { | ||
try { | ||
let data = createValueFunc(); | ||
if (data instanceof Promise) { | ||
data = await data; | ||
} | ||
return data; | ||
} catch (err) { | ||
this.logger.error(`An error occurred while trying to load value.`, { | ||
path: 'redis-cache.service.createValueFunc', | ||
exception: err, | ||
key, | ||
}); | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.