@jayfong/x-server 1.27.3 → 1.28.1
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/CHANGELOG.md +21 -0
- package/lib/_cjs/cli/build_util.js +2 -2
- package/lib/_cjs/services/cache.js +23 -4
- package/lib/cli/build_util.js +2 -2
- package/lib/services/cache.d.ts +2 -1
- package/lib/services/cache.js +23 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.28.1](https://github.com/jfWorks/x-server/compare/v1.28.0...v1.28.1) (2022-05-16)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* rhel-openssl-1.1.x ([38bbf2f](https://github.com/jfWorks/x-server/commit/38bbf2ff3b1b22eaf37eebb7bca5bc95ee8c90a0))
|
|
11
|
+
|
|
12
|
+
## [1.28.0](https://github.com/jfWorks/x-server/compare/v1.27.4...v1.28.0) (2022-05-15)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **cache:** add rememberMany ([d6460d3](https://github.com/jfWorks/x-server/commit/d6460d363000700745834c02d145ec86658400d1))
|
|
18
|
+
|
|
19
|
+
### [1.27.4](https://github.com/jfWorks/x-server/compare/v1.27.3...v1.27.4) (2022-05-15)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* cache remove use batch ([1075902](https://github.com/jfWorks/x-server/commit/1075902984e09e766ec72b0289c4e4a5d16d5d16))
|
|
25
|
+
|
|
5
26
|
### [1.27.3](https://github.com/jfWorks/x-server/compare/v1.27.2...v1.27.3) (2022-05-11)
|
|
6
27
|
|
|
7
28
|
|
|
@@ -123,12 +123,12 @@ class BuildUtil {
|
|
|
123
123
|
const prismaSchemaFile = _nodePath.default.join(options.cwd, 'src/db/schema.prisma');
|
|
124
124
|
|
|
125
125
|
if (await _fsExtra.default.pathExists(prismaSchemaFile)) {
|
|
126
|
-
// 下载 centos (rhel-openssl-1.0.x) 的可执行文件
|
|
126
|
+
// 下载 centos (rhel-openssl-1.0.x,rhel-openssl-1.1.x) 的可执行文件
|
|
127
127
|
await (0, _execa.default)('tbify', ['node', require.resolve('@prisma/engines/download/index.js')], {
|
|
128
128
|
env: {
|
|
129
129
|
// https://www.prisma.io/docs/reference/api-reference/environment-variables-reference#prisma_cli_binary_targets
|
|
130
130
|
// https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#binarytargets-options
|
|
131
|
-
PRISMA_CLI_BINARY_TARGETS: `${_os.default.platform() === 'darwin' ? 'darwin' : 'windows'},rhel-openssl-1.0.x`
|
|
131
|
+
PRISMA_CLI_BINARY_TARGETS: `${_os.default.platform() === 'darwin' ? 'darwin' : 'windows'},rhel-openssl-1.0.x,rhel-openssl-1.1.x`
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
134
|
|
|
@@ -115,6 +115,28 @@ class CacheService {
|
|
|
115
115
|
|
|
116
116
|
return value;
|
|
117
117
|
}
|
|
118
|
+
|
|
119
|
+
async rememberMany(raws, key, action, ttl = this.options.ttl) {
|
|
120
|
+
const keys = raws.map(key);
|
|
121
|
+
const values = await this.getMany(...keys);
|
|
122
|
+
const shouldUpdateIndexes = [];
|
|
123
|
+
|
|
124
|
+
for (let i = 0, len = values.length; i < len; i++) {
|
|
125
|
+
if (values[i] === null) {
|
|
126
|
+
shouldUpdateIndexes.push(i);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (shouldUpdateIndexes.length) {
|
|
131
|
+
const nextValues = await action(shouldUpdateIndexes.map(i => raws[i]));
|
|
132
|
+
await Promise.all(nextValues.map(async (nextValue, index) => {
|
|
133
|
+
values[shouldUpdateIndexes[index]] = nextValue;
|
|
134
|
+
await this.set(keys[shouldUpdateIndexes[index]], nextValue, ttl);
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return values;
|
|
139
|
+
}
|
|
118
140
|
/**
|
|
119
141
|
* 自增。
|
|
120
142
|
*
|
|
@@ -182,10 +204,7 @@ class CacheService {
|
|
|
182
204
|
|
|
183
205
|
|
|
184
206
|
async remove(...keys) {
|
|
185
|
-
return
|
|
186
|
-
const redisKey = this.toRedisKey(key);
|
|
187
|
-
return _x.x.redis.del(redisKey);
|
|
188
|
-
}));
|
|
207
|
+
return _x.x.redis.del(...keys.map(key => this.toRedisKey(key)));
|
|
189
208
|
}
|
|
190
209
|
/**
|
|
191
210
|
* 清空全部缓存。
|
package/lib/cli/build_util.js
CHANGED
|
@@ -99,12 +99,12 @@ export class BuildUtil {
|
|
|
99
99
|
const prismaSchemaFile = path.join(options.cwd, 'src/db/schema.prisma');
|
|
100
100
|
|
|
101
101
|
if (await fs.pathExists(prismaSchemaFile)) {
|
|
102
|
-
// 下载 centos (rhel-openssl-1.0.x) 的可执行文件
|
|
102
|
+
// 下载 centos (rhel-openssl-1.0.x,rhel-openssl-1.1.x) 的可执行文件
|
|
103
103
|
await execa('tbify', ['node', require.resolve('@prisma/engines/download/index.js')], {
|
|
104
104
|
env: {
|
|
105
105
|
// https://www.prisma.io/docs/reference/api-reference/environment-variables-reference#prisma_cli_binary_targets
|
|
106
106
|
// https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#binarytargets-options
|
|
107
|
-
PRISMA_CLI_BINARY_TARGETS: `${os.platform() === 'darwin' ? 'darwin' : 'windows'},rhel-openssl-1.0.x`
|
|
107
|
+
PRISMA_CLI_BINARY_TARGETS: `${os.platform() === 'darwin' ? 'darwin' : 'windows'},rhel-openssl-1.0.x,rhel-openssl-1.1.x`
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
const distPrismaSchemaFile = path.join(distDir, 'schema.prisma');
|
package/lib/services/cache.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export declare class CacheService<TData extends Data = Data, TKey extends Key<TD
|
|
|
61
61
|
* @returns 返回获取到的内容
|
|
62
62
|
*/
|
|
63
63
|
remember<K extends TKeyPath, V extends Value<TData, K>>(key: K, action: () => V | Promise<V>, ttl?: MsValue | ((data: V, defaultTTL: MsValue) => MsValue)): Promise<V>;
|
|
64
|
+
rememberMany<T, K extends TKeyPath, V extends Value<TData, K>>(raws: T[], key: (raw: T) => K, action: (raws: T[]) => V[] | Promise<V[]>, ttl?: MsValue | ((data: V, defaultTTL: MsValue) => MsValue)): Promise<V[]>;
|
|
64
65
|
/**
|
|
65
66
|
* 自增。
|
|
66
67
|
*
|
|
@@ -94,7 +95,7 @@ export declare class CacheService<TData extends Data = Data, TKey extends Key<TD
|
|
|
94
95
|
*
|
|
95
96
|
* @param keys 键列表
|
|
96
97
|
*/
|
|
97
|
-
remove<K extends TKeyPath>(...keys: K[]): Promise<
|
|
98
|
+
remove<K extends TKeyPath>(...keys: K[]): Promise<number>;
|
|
98
99
|
/**
|
|
99
100
|
* 清空全部缓存。
|
|
100
101
|
*/
|
package/lib/services/cache.js
CHANGED
|
@@ -105,6 +105,28 @@ export class CacheService {
|
|
|
105
105
|
|
|
106
106
|
return value;
|
|
107
107
|
}
|
|
108
|
+
|
|
109
|
+
async rememberMany(raws, key, action, ttl = this.options.ttl) {
|
|
110
|
+
const keys = raws.map(key);
|
|
111
|
+
const values = await this.getMany(...keys);
|
|
112
|
+
const shouldUpdateIndexes = [];
|
|
113
|
+
|
|
114
|
+
for (let i = 0, len = values.length; i < len; i++) {
|
|
115
|
+
if (values[i] === null) {
|
|
116
|
+
shouldUpdateIndexes.push(i);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (shouldUpdateIndexes.length) {
|
|
121
|
+
const nextValues = await action(shouldUpdateIndexes.map(i => raws[i]));
|
|
122
|
+
await Promise.all(nextValues.map(async (nextValue, index) => {
|
|
123
|
+
values[shouldUpdateIndexes[index]] = nextValue;
|
|
124
|
+
await this.set(keys[shouldUpdateIndexes[index]], nextValue, ttl);
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return values;
|
|
129
|
+
}
|
|
108
130
|
/**
|
|
109
131
|
* 自增。
|
|
110
132
|
*
|
|
@@ -172,10 +194,7 @@ export class CacheService {
|
|
|
172
194
|
|
|
173
195
|
|
|
174
196
|
async remove(...keys) {
|
|
175
|
-
return
|
|
176
|
-
const redisKey = this.toRedisKey(key);
|
|
177
|
-
return x.redis.del(redisKey);
|
|
178
|
-
}));
|
|
197
|
+
return x.redis.del(...keys.map(key => this.toRedisKey(key)));
|
|
179
198
|
}
|
|
180
199
|
/**
|
|
181
200
|
* 清空全部缓存。
|