Skip to content

Add in-flight request deduplication for identical reads #90

Description

@Lakes41

Difficulty: Advanced

Type: Feature

Summary

Deduplicate concurrent identical read requests so the SDK does not issue multiple network calls for the same access, membership, role, or guild lookup at the same time.

Current Behaviour

Caching only helps after the first request has completed. If multiple callers request the same key concurrently, each call can still hit the network.

Expected Behaviour

When cache is enabled, concurrent identical reads should share the same in-flight promise and resolve to the same result.

Suggested Implementation

Add an internal in-flight request map keyed by the same cache key used for read caching. Remove entries after resolution or rejection. Ensure rejected requests do not poison future calls.

Files or Areas Likely Affected

  • src/client/GuildPassClient.ts
  • src/cache/cache.types.ts
  • tests/client.test.ts
  • tests/services.test.ts
  • docs/sdk-guide.md

Acceptance Criteria

  • Concurrent identical guild reads share one network request
  • Concurrent identical membership reads share one network request
  • Rejected in-flight requests are removed from the deduplication map
  • Successful requests are still written to cache
  • Deduplication is scoped by full cache key
  • Tests prove only one raw service call occurs for concurrent identical reads

Additional Notes

This should be enabled only for safe read operations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions