aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/models/index.ts4
-rw-r--r--src/models/key-value-cache.ts (renamed from src/models/cache.ts)2
-rw-r--r--src/services/cache.ts6
-rw-r--r--src/utils/db.ts4
4 files changed, 8 insertions, 8 deletions
diff --git a/src/models/index.ts b/src/models/index.ts
index fec0c8e..d39a3dc 100644
--- a/src/models/index.ts
+++ b/src/models/index.ts
@@ -1,9 +1,9 @@
-import Cache from './cache.js';
+import KeyValueCache from './key-value-cache.js';
import Settings from './settings.js';
import Shortcut from './shortcut.js';
export {
- Cache,
+ KeyValueCache,
Settings,
Shortcut,
};
diff --git a/src/models/cache.ts b/src/models/key-value-cache.ts
index ebf8dad..795ff75 100644
--- a/src/models/cache.ts
+++ b/src/models/key-value-cache.ts
@@ -2,7 +2,7 @@ import {Table, Column, PrimaryKey, Model} from 'sequelize-typescript';
import sequelize from 'sequelize';
@Table
-export default class Cache extends Model<Cache> {
+export default class KeyValueCache extends Model<KeyValueCache> {
@PrimaryKey
@Column
key!: string;
diff --git a/src/services/cache.ts b/src/services/cache.ts
index e877c56..95c6731 100644
--- a/src/services/cache.ts
+++ b/src/services/cache.ts
@@ -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),
diff --git a/src/utils/db.ts b/src/utils/db.ts
index be42013..f7d4fff 100644
--- a/src/utils/db.ts
+++ b/src/utils/db.ts
@@ -1,12 +1,12 @@
import {Sequelize} from 'sequelize-typescript';
import path from 'path';
import {DATA_DIR} from '../services/config.js';
-import {Cache, Settings, Shortcut} from '../models/index.js';
+import {KeyValueCache, Settings, Shortcut} from '../models/index.js';
export const sequelize = new Sequelize({
dialect: 'sqlite',
database: 'muse',
storage: path.join(DATA_DIR, 'db.sqlite'),
- models: [Cache, Settings, Shortcut],
+ models: [KeyValueCache, Settings, Shortcut],
logging: false,
});