simple-graphql
Advanced tools
Comparing version 5.2.2 to 5.2.3
@@ -325,9 +325,4 @@ import { GraphQLFieldResolver, GraphQLInputType, GraphQLInterfaceType, GraphQLOutputType, GraphQLResolveInfo } from 'graphql'; | ||
}; | ||
export interface SGCacheManager { | ||
get: (key: string) => Promise<any>; | ||
set: (key: string, value: any, expire?: number) => Promise<void>; | ||
del: (pattern: string) => Promise<number>; | ||
} | ||
export * from './definition'; | ||
export * from './build'; | ||
export * from './plugin'; |
@@ -1,3 +0,4 @@ | ||
import { SGCacheManager, SGModel, SGModelCtrl } from '../../index'; | ||
import { SGModel, SGModelCtrl } from '../../index'; | ||
import { CountOptions, FindOptions } from 'sequelize'; | ||
import { SGCacheManager } from './SGCacheManager'; | ||
export default class Cache<M extends SGModel> { | ||
@@ -14,3 +15,3 @@ prefix: string; | ||
}); | ||
buildCacheKey(method: string, options?: FindOptions | CountOptions): string; | ||
private buildCacheKey; | ||
isCacheValid(options?: FindOptions | CountOptions): Promise<boolean>; | ||
@@ -17,0 +18,0 @@ findAll(options?: FindOptions): Promise<M[]>; |
@@ -16,3 +16,2 @@ "use strict"; | ||
const sequelize_1 = __importDefault(require("sequelize")); | ||
const getFindOptionsKey_1 = __importDefault(require("./getFindOptionsKey")); | ||
const getIncludeModeNames_1 = __importDefault(require("./getIncludeModeNames")); | ||
@@ -29,6 +28,4 @@ const dataToInstance_1 = __importDefault(require("./dataToInstance")); | ||
buildCacheKey(method, options) { | ||
options = options || {}; | ||
const self = this; | ||
const relateModelNames = [self.model.name, ...(0, getIncludeModeNames_1.default)(options)]; | ||
return `${self.prefix}|${method}|${relateModelNames.join('|')}|${(0, getFindOptionsKey_1.default)(self.model, options)}`; | ||
return `${self.prefix}|${self.cacheManger.buildCacheKey(self.model, method, options)}`; | ||
} | ||
@@ -35,0 +32,0 @@ isCacheValid(options) { |
@@ -1,4 +0,4 @@ | ||
import { SGCacheManager } from '../../index'; | ||
import { LRUMap } from 'lru_map'; | ||
export default class LruCacheManager implements SGCacheManager { | ||
import { SGCacheManager } from './SGCacheManager'; | ||
export declare class LruCacheManager extends SGCacheManager { | ||
cacheMap: LRUMap<string, any>; | ||
@@ -5,0 +5,0 @@ constructor(limit?: number); |
@@ -12,5 +12,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LruCacheManager = void 0; | ||
const lru_map_1 = require("lru_map"); | ||
class LruCacheManager { | ||
const SGCacheManager_1 = require("./SGCacheManager"); | ||
class LruCacheManager extends SGCacheManager_1.SGCacheManager { | ||
constructor(limit = 1000) { | ||
super(); | ||
this.cacheMap = new lru_map_1.LRUMap(limit); | ||
@@ -42,3 +45,3 @@ } | ||
} | ||
exports.default = LruCacheManager; | ||
exports.LruCacheManager = LruCacheManager; | ||
//# sourceMappingURL=LruCacheManager.js.map |
@@ -1,2 +0,3 @@ | ||
import { SGCacheManager, SGPluginConfig, SGPluginOptions } from '../index'; | ||
import { SGPluginConfig, SGPluginOptions } from '../index'; | ||
import { SGCacheManager } from './cache'; | ||
type CacheOptions = SGPluginOptions & { | ||
@@ -3,0 +4,0 @@ prefix?: string; |
@@ -16,3 +16,3 @@ "use strict"; | ||
const sequelize_1 = __importDefault(require("sequelize")); | ||
const LruCacheManager_1 = __importDefault(require("./cache/LruCacheManager")); | ||
const cache_1 = require("./cache"); | ||
const Cache_1 = __importDefault(require("./cache/Cache")); | ||
@@ -30,3 +30,3 @@ exports.default = { | ||
if (self.cacheManager == null) { | ||
self.cacheManager = (options === null || options === void 0 ? void 0 : options.cacheManager) || new LruCacheManager_1.default(); | ||
self.cacheManager = (options === null || options === void 0 ? void 0 : options.cacheManager) || new cache_1.LruCacheManager(); | ||
} | ||
@@ -33,0 +33,0 @@ const cache = new Cache_1.default({ |
@@ -13,3 +13,4 @@ export * as addMutationPlugin from './addMutationPlugin'; | ||
export * as versionPlugin from './versionPlugin'; | ||
export * from './cache'; | ||
declare const _default: import("..").SGPluginConfig<import("..").SGPluginOptions>[]; | ||
export default _default; |
@@ -25,2 +25,5 @@ "use strict"; | ||
}; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -55,2 +58,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
exports.versionPlugin = __importStar(require("./versionPlugin")); | ||
__exportStar(require("./cache"), exports); | ||
exports.default = [ | ||
@@ -57,0 +61,0 @@ addMutationPlugin_1.default, |
{ | ||
"name": "simple-graphql", | ||
"version": "5.2.2", | ||
"version": "5.2.3", | ||
"description": "The simple way to generates GraphQL schemas and Sequelize models from your models definition.", | ||
@@ -56,3 +56,4 @@ "main": "dist/index.js", | ||
"ts-jest": "^26.4.4", | ||
"ts-node": "^9.1.1", | ||
"ts-node": "^10.9.1", | ||
"typedoc": "^0.23.23", | ||
"typescript": "^4.9.4", | ||
@@ -59,0 +60,0 @@ "ws": "^8.11.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3111777
265
6695
18