midway-fatcms 0.0.1-beta.66 → 0.0.1-beta.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/models/bizmodels.d.ts +1 -1
- package/dist/service/base/cache/CacheServiceFactory.d.ts +2 -2
- package/dist/service/base/cache/CacheServiceFactory.js +10 -10
- package/dist/service/base/cache/{FatcmsBaseCtxCache.d.ts → CtxCache.d.ts} +2 -2
- package/dist/service/base/cache/{FatcmsBaseCtxCache.js → CtxCache.js} +3 -3
- package/dist/service/base/cache/{FatcmsBaseDiskCache.d.ts → DiskCache.d.ts} +2 -2
- package/dist/service/base/cache/{FatcmsBaseMemoryCache.d.ts → MemoryCache.d.ts} +2 -2
- package/dist/service/base/cache/{FatcmsBaseMemoryCache.js → MemoryCache.js} +3 -3
- package/dist/service/base/cache/{FatcmsBaseNoneCache.d.ts → NoneCache.d.ts} +2 -2
- package/dist/service/base/cache/{FatcmsBaseNoneCache.js → NoneCache.js} +3 -3
- package/dist/service/base/cache/{FatcmsBaseRedisCache.d.ts → RedisCache.d.ts} +2 -2
- package/dist/service/base/cache/{FatcmsBaseRedisCache.js → RedisCache.js} +3 -3
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/models/bizmodels.ts +1 -1
- package/src/service/UserSessionService.ts +2 -2
- package/src/service/base/cache/CacheServiceFactory.ts +11 -11
- package/src/service/base/cache/{FatcmsBaseCtxCache.ts → CtxCache.ts} +2 -2
- package/src/service/base/cache/{FatcmsBaseDiskCache.ts → DiskCache.ts} +4 -4
- package/src/service/base/cache/{FatcmsBaseMemoryCache.ts → MemoryCache.ts} +2 -2
- package/src/service/base/cache/{FatcmsBaseNoneCache.ts → NoneCache.ts} +3 -3
- package/src/service/base/cache/{FatcmsBaseRedisCache.ts → RedisCache.ts} +3 -3
- /package/dist/service/base/cache/{FatcmsBaseDiskCache.js → DiskCache.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export * from './service/anyapi/AnyApiSandboxService';
|
|
|
54
54
|
export * from './service/anyapi/AnyApiService';
|
|
55
55
|
export * from './service/base/ApiBaseService';
|
|
56
56
|
export * from './service/base/BaseService';
|
|
57
|
-
export * from './service/base/cache/
|
|
57
|
+
export * from './service/base/cache/CacheServiceFactory';
|
|
58
58
|
export * from './service/crudstd/CrudStdActionService';
|
|
59
59
|
export * from './service/crudstd/CrudStdRelationService';
|
|
60
60
|
export * from './service/crudstd/CrudStdService';
|
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ __exportStar(require("./service/anyapi/AnyApiSandboxService"), exports);
|
|
|
72
72
|
__exportStar(require("./service/anyapi/AnyApiService"), exports);
|
|
73
73
|
__exportStar(require("./service/base/ApiBaseService"), exports);
|
|
74
74
|
__exportStar(require("./service/base/BaseService"), exports);
|
|
75
|
-
__exportStar(require("./service/base/cache/
|
|
75
|
+
__exportStar(require("./service/base/cache/CacheServiceFactory"), exports);
|
|
76
76
|
__exportStar(require("./service/crudstd/CrudStdActionService"), exports);
|
|
77
77
|
__exportStar(require("./service/crudstd/CrudStdRelationService"), exports);
|
|
78
78
|
__exportStar(require("./service/crudstd/CrudStdService"), exports);
|
|
@@ -102,7 +102,7 @@ export interface IStdCrudExportInputParams {
|
|
|
102
102
|
primaryKey: any;
|
|
103
103
|
pageSize: number;
|
|
104
104
|
}
|
|
105
|
-
export interface
|
|
105
|
+
export interface ICacheService {
|
|
106
106
|
getJsonObject(key: string): Promise<any>;
|
|
107
107
|
setJsonObject(key: string, obj: any, cacheSecond?: number): Promise<any>;
|
|
108
108
|
removeItem(key: string): Promise<any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
|
-
import {
|
|
2
|
+
import { ICacheService } from '../../../models/bizmodels';
|
|
3
3
|
import { CacheLevelEnum, CacheNameEnum } from '../../../models/SystemEntities';
|
|
4
4
|
import { RedisService } from '@midwayjs/redis';
|
|
5
5
|
interface IGetJsonObjectCacheParam {
|
|
@@ -14,7 +14,7 @@ export declare class CacheServiceFactory {
|
|
|
14
14
|
protected ctx: Context;
|
|
15
15
|
private fatcmsCache;
|
|
16
16
|
protected redisService: RedisService;
|
|
17
|
-
getCacheService(cacheLevelEnum: CacheLevelEnum, cacheName: CacheNameEnum):
|
|
17
|
+
getCacheService(cacheLevelEnum: CacheLevelEnum, cacheName: CacheNameEnum): ICacheService;
|
|
18
18
|
getJsonObjectCache(param: IGetJsonObjectCacheParam): Promise<any>;
|
|
19
19
|
}
|
|
20
20
|
export {};
|
|
@@ -13,24 +13,24 @@ exports.CacheServiceFactory = void 0;
|
|
|
13
13
|
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const SystemEntities_1 = require("../../../models/SystemEntities");
|
|
15
15
|
const redis_1 = require("@midwayjs/redis");
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
16
|
+
const CtxCache_1 = require("./CtxCache");
|
|
17
|
+
const RedisCache_1 = require("./RedisCache");
|
|
18
|
+
const DiskCache_1 = require("./DiskCache");
|
|
19
|
+
const MemoryCache_1 = require("./MemoryCache");
|
|
20
|
+
const NoneCache_1 = require("./NoneCache");
|
|
21
21
|
let CacheServiceFactory = class CacheServiceFactory {
|
|
22
22
|
getCacheService(cacheLevelEnum, cacheName) {
|
|
23
23
|
switch (cacheLevelEnum) {
|
|
24
24
|
case SystemEntities_1.CacheLevelEnum.CONTEXT:
|
|
25
|
-
return new
|
|
25
|
+
return new CtxCache_1.CtxCache(this.ctx, cacheName);
|
|
26
26
|
case SystemEntities_1.CacheLevelEnum.REDIS:
|
|
27
|
-
return new
|
|
27
|
+
return new RedisCache_1.RedisCache(this.ctx, cacheName, this.redisService);
|
|
28
28
|
case SystemEntities_1.CacheLevelEnum.DISK:
|
|
29
|
-
return new
|
|
29
|
+
return new DiskCache_1.FatcmsBaseDiskCache(this.ctx, cacheName, this.fatcmsCache);
|
|
30
30
|
case SystemEntities_1.CacheLevelEnum.MEMORY:
|
|
31
|
-
return new
|
|
31
|
+
return new MemoryCache_1.MemoryCache(this.ctx, cacheName);
|
|
32
32
|
default:
|
|
33
|
-
return new
|
|
33
|
+
return new NoneCache_1.NoneCache(this.ctx, cacheName);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
async getJsonObjectCache(param) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ICacheService } from '../../../models/bizmodels';
|
|
2
2
|
import { CacheNameEnum } from '../../../models/SystemEntities';
|
|
3
3
|
import { Context } from '@midwayjs/koa';
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class CtxCache implements ICacheService {
|
|
5
5
|
private ctx;
|
|
6
6
|
private cacheName;
|
|
7
7
|
constructor(ctx: Context, cacheName: CacheNameEnum);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
class
|
|
3
|
+
exports.CtxCache = void 0;
|
|
4
|
+
class CtxCache {
|
|
5
5
|
constructor(ctx, cacheName) {
|
|
6
6
|
this.ctx = ctx;
|
|
7
7
|
this.cacheName = cacheName;
|
|
@@ -35,4 +35,4 @@ class FatcmsBaseCtxCache {
|
|
|
35
35
|
cacheMap.delete(key);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
exports.
|
|
38
|
+
exports.CtxCache = CtxCache;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
|
-
import {
|
|
3
|
-
export declare class FatcmsBaseDiskCache implements
|
|
2
|
+
import { ICacheService, IfatcmsCacheConfig } from '../../../models/bizmodels';
|
|
3
|
+
export declare class FatcmsBaseDiskCache implements ICacheService {
|
|
4
4
|
protected ctx: Context;
|
|
5
5
|
protected cacheName: string;
|
|
6
6
|
private fatcmsCache;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
|
-
import {
|
|
3
|
-
export declare class
|
|
2
|
+
import { ICacheService } from '../../../models/bizmodels';
|
|
3
|
+
export declare class MemoryCache implements ICacheService {
|
|
4
4
|
protected ctx: Context;
|
|
5
5
|
protected cacheName: string;
|
|
6
6
|
constructor(ctx: Context, cacheName: string);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MemoryCache = void 0;
|
|
4
4
|
const lru_cache_1 = require("lru-cache");
|
|
5
5
|
const LRU_CACHE_MAP = new Map();
|
|
6
|
-
class
|
|
6
|
+
class MemoryCache {
|
|
7
7
|
constructor(ctx, cacheName) {
|
|
8
8
|
this.ctx = ctx;
|
|
9
9
|
this.cacheName = cacheName;
|
|
@@ -63,4 +63,4 @@ class FatcmsBaseMemoryCache {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
exports.
|
|
66
|
+
exports.MemoryCache = MemoryCache;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ICacheService } from '../../../models/bizmodels';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class NoneCache implements ICacheService {
|
|
4
4
|
protected ctx: Context;
|
|
5
5
|
protected cacheName: string;
|
|
6
6
|
constructor(ctx: Context, cacheName: string);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
class
|
|
3
|
+
exports.NoneCache = void 0;
|
|
4
|
+
class NoneCache {
|
|
5
5
|
constructor(ctx, cacheName) {
|
|
6
6
|
this.ctx = ctx;
|
|
7
7
|
this.cacheName = cacheName;
|
|
@@ -16,4 +16,4 @@ class FatcmsBaseNoneCache {
|
|
|
16
16
|
return true;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
exports.
|
|
19
|
+
exports.NoneCache = NoneCache;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
2
|
import { RedisService } from '@midwayjs/redis';
|
|
3
|
-
import {
|
|
4
|
-
export declare class
|
|
3
|
+
import { ICacheService } from '../../../models/bizmodels';
|
|
4
|
+
export declare class RedisCache implements ICacheService {
|
|
5
5
|
protected ctx: Context;
|
|
6
6
|
protected cacheName: string;
|
|
7
7
|
protected redisService: RedisService;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RedisCache = void 0;
|
|
4
4
|
const functions_1 = require("../../../libs/utils/functions");
|
|
5
|
-
class
|
|
5
|
+
class RedisCache {
|
|
6
6
|
constructor(ctx, cacheName, redisService) {
|
|
7
7
|
this.ctx = ctx;
|
|
8
8
|
this.cacheName = cacheName;
|
|
@@ -36,4 +36,4 @@ class FatcmsBaseRedisCache {
|
|
|
36
36
|
return await this.redisService.del(cacheKey);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
exports.
|
|
39
|
+
exports.RedisCache = RedisCache;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -54,7 +54,7 @@ export * from './service/anyapi/AnyApiSandboxService';
|
|
|
54
54
|
export * from './service/anyapi/AnyApiService';
|
|
55
55
|
export * from './service/base/ApiBaseService';
|
|
56
56
|
export * from './service/base/BaseService';
|
|
57
|
-
export * from './service/base/cache/
|
|
57
|
+
export * from './service/base/cache/CacheServiceFactory';
|
|
58
58
|
export * from './service/crudstd/CrudStdActionService';
|
|
59
59
|
export * from './service/crudstd/CrudStdRelationService';
|
|
60
60
|
export * from './service/crudstd/CrudStdService';
|
package/src/models/bizmodels.ts
CHANGED
|
@@ -126,7 +126,7 @@ export interface IStdCrudExportInputParams {
|
|
|
126
126
|
pageSize: number; // 公共
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
export interface
|
|
129
|
+
export interface ICacheService {
|
|
130
130
|
getJsonObject(key: string): Promise<any>;
|
|
131
131
|
setJsonObject(key: string, obj: any, cacheSecond?: number): Promise<any>;
|
|
132
132
|
removeItem(key: string): Promise<any>;
|
|
@@ -9,7 +9,7 @@ import { SystemTables } from '@/models/SystemTables';
|
|
|
9
9
|
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
10
10
|
import { CacheServiceFactory } from './base/cache/CacheServiceFactory';
|
|
11
11
|
import { CacheLevelEnum, CacheNameEnum } from '@/models/SystemEntities';
|
|
12
|
-
import {
|
|
12
|
+
import { ICacheService } from '@/models/bizmodels';
|
|
13
13
|
|
|
14
14
|
function pickUserAvatar(avatar: any): string {
|
|
15
15
|
if (!avatar) {
|
|
@@ -70,7 +70,7 @@ export class UserSessionService {
|
|
|
70
70
|
* 获取用户会话缓存服务
|
|
71
71
|
* @returns
|
|
72
72
|
*/
|
|
73
|
-
private getUserSessionCacheService():
|
|
73
|
+
private getUserSessionCacheService(): ICacheService {
|
|
74
74
|
return this.cacheServiceFactory.getCacheService(CacheLevelEnum.REDIS, CacheNameEnum.UserSessionBySessionId);
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Inject, Provide, Config } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import {
|
|
3
|
+
import { ICacheService, IfatcmsCacheConfig } from '@/models/bizmodels';
|
|
4
4
|
import { CacheLevelEnum, CacheNameEnum } from '@/models/SystemEntities';
|
|
5
5
|
import { RedisService } from '@midwayjs/redis';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { FatcmsBaseDiskCache } from './
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
6
|
+
import { CtxCache } from './CtxCache';
|
|
7
|
+
import { RedisCache } from './RedisCache';
|
|
8
|
+
import { FatcmsBaseDiskCache } from './DiskCache';
|
|
9
|
+
import { MemoryCache } from './MemoryCache';
|
|
10
|
+
import { NoneCache } from './NoneCache';
|
|
11
11
|
|
|
12
12
|
interface IGetJsonObjectCacheParam {
|
|
13
13
|
cacheLevel: CacheLevelEnum;
|
|
@@ -29,18 +29,18 @@ export class CacheServiceFactory {
|
|
|
29
29
|
@Inject()
|
|
30
30
|
protected redisService: RedisService;
|
|
31
31
|
|
|
32
|
-
public getCacheService(cacheLevelEnum: CacheLevelEnum, cacheName: CacheNameEnum):
|
|
32
|
+
public getCacheService(cacheLevelEnum: CacheLevelEnum, cacheName: CacheNameEnum): ICacheService {
|
|
33
33
|
switch (cacheLevelEnum) {
|
|
34
34
|
case CacheLevelEnum.CONTEXT:
|
|
35
|
-
return new
|
|
35
|
+
return new CtxCache(this.ctx, cacheName);
|
|
36
36
|
case CacheLevelEnum.REDIS:
|
|
37
|
-
return new
|
|
37
|
+
return new RedisCache(this.ctx, cacheName, this.redisService);
|
|
38
38
|
case CacheLevelEnum.DISK:
|
|
39
39
|
return new FatcmsBaseDiskCache(this.ctx, cacheName, this.fatcmsCache);
|
|
40
40
|
case CacheLevelEnum.MEMORY:
|
|
41
|
-
return new
|
|
41
|
+
return new MemoryCache(this.ctx, cacheName);
|
|
42
42
|
default:
|
|
43
|
-
return new
|
|
43
|
+
return new NoneCache(this.ctx, cacheName);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ICacheService } from '@/models/bizmodels';
|
|
2
2
|
import { CacheNameEnum } from '@/models/SystemEntities';
|
|
3
3
|
import { Context } from '@midwayjs/koa';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
export class
|
|
7
|
+
export class CtxCache implements ICacheService {
|
|
8
8
|
private ctx: Context;
|
|
9
9
|
private cacheName: CacheNameEnum;
|
|
10
10
|
|
|
@@ -3,11 +3,11 @@ import * as md5 from 'md5';
|
|
|
3
3
|
import * as fs from 'fs/promises';
|
|
4
4
|
import * as fs2 from 'fs';
|
|
5
5
|
import * as path from 'path';
|
|
6
|
-
import { parseJsonObject } from '
|
|
7
|
-
import {
|
|
6
|
+
import { parseJsonObject } from '@/libs/utils/functions';
|
|
7
|
+
import { ICacheService, IfatcmsCacheConfig } from '@/models/bizmodels';
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
export class FatcmsBaseDiskCache implements
|
|
10
|
+
export class FatcmsBaseDiskCache implements ICacheService {
|
|
11
11
|
protected ctx: Context;
|
|
12
12
|
protected cacheName: string;
|
|
13
13
|
private fatcmsCache: IfatcmsCacheConfig;
|
|
@@ -30,7 +30,7 @@ export class FatcmsBaseDiskCache implements ICacheServiceBase {
|
|
|
30
30
|
if (checkDirExist) {
|
|
31
31
|
const isDirExist = await fs2.promises.access(cacheDir).then(() => true, () => false);
|
|
32
32
|
if (!isDirExist) {
|
|
33
|
-
await fs2.promises.mkdir(cacheDir, { recursive: true });
|
|
33
|
+
await fs2.promises.mkdir(cacheDir, { recursive: true });
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
return path.join(cacheDir, `${md5(key)}.json`);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
2
|
import { LRUCache } from 'lru-cache';
|
|
3
|
-
import {
|
|
3
|
+
import { ICacheService } from '@/models/bizmodels';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
const LRU_CACHE_MAP = new Map<string, LRUCache<string, any>>();
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
export class
|
|
10
|
+
export class MemoryCache implements ICacheService {
|
|
11
11
|
protected ctx: Context;
|
|
12
12
|
protected cacheName: string;
|
|
13
13
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ICacheService } from '@/models/bizmodels';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
|
|
4
|
-
export class
|
|
4
|
+
export class NoneCache implements ICacheService {
|
|
5
5
|
protected ctx: Context;
|
|
6
6
|
protected cacheName: string;
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
constructor(ctx: Context, cacheName: string) {
|
|
9
9
|
this.ctx = ctx;
|
|
10
10
|
this.cacheName = cacheName;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
2
|
import { RedisService } from '@midwayjs/redis';
|
|
3
|
-
import { parseJsonObject } from '
|
|
4
|
-
import {
|
|
3
|
+
import { parseJsonObject } from '@/libs/utils/functions';
|
|
4
|
+
import { ICacheService } from '@/models/bizmodels';
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
export class
|
|
7
|
+
export class RedisCache implements ICacheService {
|
|
8
8
|
protected ctx: Context;
|
|
9
9
|
protected cacheName: string;
|
|
10
10
|
protected redisService: RedisService;
|
|
File without changes
|