MCPcopy
hub / github.com/msgbyte/tianji / getLockInfo

Method getLockInfo

src/server/cache/distributedLock.ts:307–334  ·  view source on GitHub ↗

* Get information about a lock * @param lockName - Name of the lock * @returns Promise - Lock information or null if not locked

(lockName: string)

Source from the content-addressed store, hash-verified

305 * @returns Promise<LockInfo | null> - Lock information or null if not locked
306 */
307 async getLockInfo(lockName: string): Promise<{
308 id: string;
309 acquiredAt: number;
310 acquiredBy: string;
311 age: number;
312 } | null> {
313 try {
314 const cacheManager = await getCacheManager();
315 const lockKey = `${this.options.prefix}:${lockName}`;
316 const existingLock = await cacheManager.get(lockKey);
317
318 if (!existingLock) {
319 return null;
320 }
321
322 const parsedLock = JSON.parse(String(existingLock));
323 return {
324 ...parsedLock,
325 age: Date.now() - parsedLock.acquiredAt,
326 };
327 } catch (error) {
328 logger.error(
329 `[DistributedLock] Error getting lock info ${lockName}:`,
330 error
331 );
332 return null;
333 }
334 }
335}
336
337// Default instance for convenience

Callers

nothing calls this directly

Calls 5

getCacheManagerFunction · 0.85
parseMethod · 0.80
nowMethod · 0.80
errorMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected