Limit concurrent cache lookups
This commit is contained in:
@@ -87,15 +87,19 @@ export const denormalizePiece = ({
|
||||
Effect.flatMap(denormalizeSystemInformation),
|
||||
);
|
||||
|
||||
const CacheSemaphore = Effect.unsafeMakeSemaphore(4);
|
||||
|
||||
export const userLookup = (userId: UserId) => pipe(
|
||||
Effect.promise((signal) => client.user({ userId }).get({ fetch: { signal } })),
|
||||
Effect.flatMap(mapResponse),
|
||||
CacheSemaphore.withPermits(1),
|
||||
);
|
||||
|
||||
export const pieceLookup = (pieceId: PieceId) => pipe(
|
||||
Effect.promise((signal) => client.piece({ pieceId }).get({ fetch: { signal } })),
|
||||
Effect.flatMap(mapResponse),
|
||||
Effect.flatMap(denormalizePiece),
|
||||
CacheSemaphore.withPermits(1),
|
||||
);
|
||||
|
||||
export const userCache = Effect.runSync(Cache.make({
|
||||
|
||||
Reference in New Issue
Block a user