Merge branch 'io' into merge-upstream

This commit is contained in:
riku6460 2023-10-29 01:18:17 +09:00
commit f85b80f376
No known key found for this signature in database
GPG key ID: 27414FA27DB94CF6

View file

@ -52,13 +52,13 @@ export class FetchInstanceMetadataService {
@bindThis @bindThis
public async tryLock(host: string): Promise<boolean> { public async tryLock(host: string): Promise<boolean> {
const mutex = await this.redisClient.set(`fetchInstanceMetadata:mutex:${host}`, '1', 'GET'); const mutex = await this.redisClient.set(`fetchInstanceMetadata:mutex:${host}`, '1', 'EX', 60 * 5, 'NX', 'GET');
return mutex !== '1'; return mutex !== '1';
} }
@bindThis @bindThis
public unlock(host: string): Promise<'OK'> { public unlock(host: string): Promise<number> {
return this.redisClient.set(`fetchInstanceMetadata:mutex:${host}`, '0'); return this.redisClient.del(`fetchInstanceMetadata:mutex:${host}`);
} }
@bindThis @bindThis