Documentation ¶
Overview ¶
Package memorystore defines an in-memory storage system for limiting.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // Tokens is the number of tokens to allow per interval. The default value is // 1. Tokens uint64 // Interval is the time interval upon which to enforce rate limiting. The // default value is 1 second. Interval time.Duration // SweepInterval is the rate at which to run the garabage collection on stale // entries. Setting this to a low value will optimize memory consumption, but // will likely reduce performance and increase lock contention. Setting this // to a high value will maximum throughput, but will increase the memory // footprint. This can be tuned in combination with SweepMinTTL to control how // long stale entires are kept. The default value is 6 hours. SweepInterval time.Duration // SweepMinTTL is the minimum amount of time a session must be inactive before // clearing it from the entries. There's no validation, but this should be at // least as high as your rate limit, or else the data store will purge records // before they limit is applied. The default value is 12 hours. SweepMinTTL time.Duration // InitialAlloc is the size to use for the in-memory map. Go will // automatically expand the buffer, but choosing higher number can trade // memory consumption for performance as it limits the number of times the map // needs to expand. The default value is 4096. InitialAlloc int }
Config is used as input to New. It defines the behavior of the storage system.
Click to show internal directories.
Click to hide internal directories.