StellaOps.Router.Gateway.RateLimiting.Valkey

Valkey store for the environment-scope rate limit of StellaOps.Router.Gateway

library
Component
Router
Licence
BUSL-1.1 (Router licence)
Target framework
net10.0
Latest release
1.0.1-20261117T070237Z

Install

dotnet add package StellaOps.Router.Gateway.RateLimiting.Valkey --version 1.0.1-20261117T070237Z

Namespaces

NamespaceTypes
StellaOps.Router.Gateway.RateLimiting.Valkey2

namespace StellaOps.Router.Gateway.RateLimiting.Valkey

TypeKindDescription
RouterValkeyRateLimitStoreServiceCollectionExtensionsclassRegisters the Valkey store of the gateway’s environment-scope rate limit (rate_limiting:for_environment).
ValkeyRateLimitStoreclassValkey-backed fixed-window rate limit store.

class RouterValkeyRateLimitStoreServiceCollectionExtensions

public static class RouterValkeyRateLimitStoreServiceCollectionExtensions

Registers the Valkey store of the gateway’s environment-scope rate limit (rate_limiting:for_environment).

Members

MemberKindSummary
AddRouterValkeyRateLimitStore(IServiceCollection)extension methodRegisters ValkeyRateLimitStoreas the IValkeyRateLimitStoreof the environment rate limit.

extension method AddRouterValkeyRateLimitStore(IServiceCollection) #

public static IServiceCollection AddRouterValkeyRateLimitStore(this IServiceCollection services)

Registers ValkeyRateLimitStoreas the IValkeyRateLimitStoreof the environment rate limit. The store connects to rate_limiting:for_environment:valkey_connection and keeps its counters under valkey_bucket, read from the RateLimitConfigthat AddRouterRateLimiting registers; it is created only when environment rules are configured, and it connects on the first request. A store registered before this call is kept.

Parameters

  • services: The service collection.

Returns

The service collection for chaining.

class ValkeyRateLimitStore

public sealed class ValkeyRateLimitStore : IValkeyRateLimitStore, IDisposable

Valkey-backed fixed-window rate limit store.

Members

MemberKindSummary
ValkeyRateLimitStore(string, string, ILogger<ValkeyRateLimitStore>)constructorCreates a store over a Valkey server.
Dispose()methodSee IDisposable.Dispose().
IncrementAndCheckAsync(string, IReadOnlyList<RateLimitRule>, CancellationToken)methodAtomically increment counters for the provided rules and determine if the request is allowed.

constructor ValkeyRateLimitStore(string, string, ILogger<ValkeyRateLimitStore>) #

public ValkeyRateLimitStore(string connectionString, string bucket, ILogger<ValkeyRateLimitStore>? logger = null)

Creates a store over a Valkey server.

Parameters

  • connectionString: The Valkey connection string.
  • bucket: The key prefix that separates this store’s counters.
  • logger: Receives the store diagnostics; none when not set.

method Dispose() #

public void Dispose()

See IDisposable.Dispose().

method IncrementAndCheckAsync(string, IReadOnlyList<RateLimitRule>, CancellationToken) #

public Task<RateLimitStoreResult> IncrementAndCheckAsync(string key, IReadOnlyList<RateLimitRule> rules, CancellationToken cancellationToken)

Atomically increment counters for the provided rules and determine if the request is allowed.