mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-05-13 04:51:35 +02:00
Rename existing cache model
This commit is contained in:
parent
381ee62b78
commit
d805da906a
4 changed files with 8 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
|||
import {injectable} from 'inversify';
|
||||
import {Cache} from '../models/index.js';
|
||||
import {KeyValueCache} from '../models/index.js';
|
||||
import debug from '../utils/debug.js';
|
||||
|
||||
type Seconds = number;
|
||||
|
@ -29,7 +29,7 @@ export default class CacheProvider {
|
|||
throw new Error(`Cache key ${key} is too short.`);
|
||||
}
|
||||
|
||||
const cachedResult = await Cache.findByPk(key);
|
||||
const cachedResult = await KeyValueCache.findByPk(key);
|
||||
|
||||
if (cachedResult) {
|
||||
if (new Date() < cachedResult.expiresAt) {
|
||||
|
@ -45,7 +45,7 @@ export default class CacheProvider {
|
|||
const result = await func(...options as any[]);
|
||||
|
||||
// Save result
|
||||
await Cache.upsert({
|
||||
await KeyValueCache.upsert({
|
||||
key,
|
||||
value: JSON.stringify(result),
|
||||
expiresAt: futureTimeToDate(expiresIn),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue