Skip to content

Instantly share code, notes, and snippets.

@abouzarnouri
abouzarnouri / RateLimiter.cs
Last active April 30, 2018 09:45
Simple invocation rate checker
using System;
using System.Runtime.Caching;
namespace Hasin.Taaghche.Utilities
{
// Use this class to put restriction on the number of invocations of an endpoint in your system by a given input.
// E.g., when a user wants to login with "test@test.com", call CanProceed("test@test.com") to check if she can do that.
public class RateLimiter
{
private readonly MemoryCache _cache;