@chevre/domain 21.1.0-alpha.1 → 21.1.0-alpha.2

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.
@@ -15,6 +15,14 @@ async function main() {
15
15
  await client.connect();
16
16
 
17
17
  console.log(await client.info());
18
+
19
+ const key = 'sampleTest';
20
+ const ttl = 60;
21
+ const results = await client.multi()
22
+ .setNX(key, '1')
23
+ .expire(key, ttl)
24
+ .exec();
25
+ console.log('results:', results);
18
26
  }
19
27
 
20
28
  main()
@@ -20,7 +20,7 @@ export declare class RedisRepository {
20
20
  /**
21
21
  * ロックする
22
22
  */
23
- lock(progressKey: IProgressKey, holder: string): Promise<number>;
23
+ lock(progressKey: IProgressKey, holder: string): Promise<boolean>;
24
24
  /**
25
25
  * メンバーシップ登録進行ロックを解除する
26
26
  */
@@ -33,8 +33,8 @@ class RedisRepository {
33
33
  .exec();
34
34
  // tslint:disable-next-line:no-single-line-block-comment
35
35
  /* istanbul ignore else: please write tests */
36
- if (results[0] === 1) {
37
- return results[0];
36
+ if (results[0] === 1 || results[0] === true) {
37
+ return true;
38
38
  }
39
39
  else {
40
40
  throw new Error('Already in progress.');
@@ -68,7 +68,7 @@ class RedisRepository {
68
68
  if (Array.isArray(results)) {
69
69
  results.slice(0, fields.length)
70
70
  .forEach((r, index) => {
71
- if (r === 1) {
71
+ if (r === 1 || r === true) {
72
72
  lockedFields.push(fields[index]);
73
73
  }
74
74
  });
@@ -52,7 +52,7 @@ class RedisRepository {
52
52
  results.forEach((r, index) => {
53
53
  debug('r, index:', r, index);
54
54
  // tslint:disable-next-line:no-magic-numbers
55
- if (index % 2 === 0 && r === 1) {
55
+ if (index % 2 === 0 && (r === 1 || r === true)) {
56
56
  // tslint:disable-next-line:no-magic-numbers
57
57
  lockedFields.push(datasets[index / 2].key);
58
58
  }
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.1.0-alpha.1"
120
+ "version": "21.1.0-alpha.2"
121
121
  }