Skip to content

Redis semaphore: current count #234

Closed

Description

@mesztam84

Hi,

is there any way to query the current number of acquired tickets of a redis semaphore? Would be great for monitoring.

Activity

  1. madelson commented on Jan 4, 2025

    @madelson
    Owner

    Currently there's no API for that. You can see how it would be implemented by looking at AcquireScript in RedisSemaphorePrimitive.cs; the first part is checking the count.

    So one option is implementing a similar script in your code.

    I also think it would be reasonable to add an API to RedisDistributedSemaphore for this:

    public int GetCurrentCount();
    public ValueTask<int> GetCurrentCountAsync();
    

    I'd be happy to review and accept such a contribution.

  2. teesofttech commented on Jul 31, 2025

    @teesofttech
    Contributor

    Hi
    Can I contribute to this?
    You can assign it to me @madelson

  3. added this to the 2.7 milestone on Aug 10, 2025
  4. madelson commented on Aug 10, 2025

    @madelson
    Owner

    Released in 2.7. Thanks @teesofttech for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions