Skip to content

Commit

Permalink
fix(platform-cache): fix cache issue
Browse files Browse the repository at this point in the history
  • Loading branch information
semantic-release-bot authored and Romakita committed Mar 28, 2022
1 parent 7c73c6a commit bcc36cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe("PlatformCacheInterceptor", () => {
set: jest.fn().mockResolvedValue(false),
del: jest.fn().mockResolvedValue(true),
ttl: jest.fn().mockResolvedValue(6999),
calculateTTL: jest.fn().mockReturnValue(10000)
calculateTTL: jest.fn().mockImplementation((result: any, ttl: any) => ttl)
};
const interceptor = await PlatformTest.invoke<PlatformCacheInterceptor>(PlatformCacheInterceptor, [
{
Expand All @@ -108,7 +108,7 @@ describe("PlatformCacheInterceptor", () => {
set: jest.fn().mockResolvedValue(false),
del: jest.fn().mockResolvedValue(true),
ttl: jest.fn().mockResolvedValue(9700),
calculateTTL: jest.fn().mockReturnValue(10000)
calculateTTL: jest.fn().mockImplementation((result: any, ttl: any) => ttl)
};
const interceptor = await PlatformTest.invoke<PlatformCacheInterceptor>(PlatformCacheInterceptor, [
{
Expand All @@ -134,7 +134,7 @@ describe("PlatformCacheInterceptor", () => {
get: jest.fn().mockResolvedValue(false),
set: jest.fn().mockResolvedValue(false),
del: jest.fn().mockResolvedValue(true),
calculateTTL: jest.fn().mockReturnValue(10000),
calculateTTL: jest.fn().mockImplementation((result: any, ttl: any) => ttl),
getCachedObject: jest.fn().mockResolvedValue({
data: JSON.stringify({data: "data"})
}),
Expand Down Expand Up @@ -185,7 +185,7 @@ describe("PlatformCacheInterceptor", () => {
get: jest.fn().mockResolvedValue(false),
set: jest.fn().mockResolvedValue(false),
del: jest.fn().mockResolvedValue(true),
calculateTTL: jest.fn().mockReturnValue(10000),
calculateTTL: jest.fn().mockImplementation((result: any, ttl: any) => ttl),
getCachedObject: jest.fn().mockResolvedValue(undefined),
setCachedObject: jest.fn().mockResolvedValue("test"),
defaultKeyResolver: () => defaultKeyResolver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class PlatformCacheInterceptor implements InterceptorMethods {
await this.addKeyToQueue(key);

const currentTTL = await this.cache.ttl(key);
const calculatedTTL = this.cache.calculateTTL(ttl);
const calculatedTTL = this.cache.calculateTTL(currentTTL, ttl);

if (currentTTL < calculatedTTL - refreshThreshold) {
await next();
Expand Down

0 comments on commit bcc36cf

Please sign in to comment.