一键导入
goyacodedevutils-yaratelimit
Fixed-window rate limiter backed by any yacache.Cache, keyed by (id, group). Use instead of hand-rolling a request-counting rate limit.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Fixed-window rate limiter backed by any yacache.Cache, keyed by (id, group). Use instead of hand-rolling a request-counting rate limit.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Index of every GoYaCodeDevUtils utility package (config, errors, logging, caching, rate limiting, backoff, hashing, gzip, RSA, feature flags, FSM, thread-safe collections, locales, Telegram bot stack) with a pointer to each package's own skill. Use before hand-rolling infrastructure code GoYaCodeDevUtils may already provide.
High-level Telegram bot framework on top of gotd/td - router/dispatcher with filters and middleware, FSM-aware routing, per-user localization, sequential-update scheduling, and a message-send queue. Use as the starting point for any Telegram bot.
Thin wrapper around gotd/td's telegram.Client adding background-connect-with-retry, bot-token authorization, updates.Manager wiring, and SOCKS5/MTProto proxy helpers. Use for direct low-level Telegram client control instead of raw gotd/td.
Redis-backed persistence for gotd/td's updates.Manager state (pts/qts/seq/date via RedisJSON) plus channel/user access-hash bookkeeping, and a GORM/AES-encrypted session-storage layer. Use for any yatgclient/yatgbot state or session persistence.
Generic pluggable key-value cache abstraction with interchangeable in-memory and Redis backends, hash-oriented API. Use for any caching/session-store need instead of hand-rolling a map or a bare redis.Client call.
Loads JSON locale files into a nested key-tree with lookup, {placeholder} formatting, JSON serving, language-tag normalization, and Go-struct codegen. Use for any i18n/localization instead of hand-rolled JSON locale loading.
| name | goyacodedevutils-yaratelimit |
| description | Fixed-window rate limiter backed by any yacache.Cache, keyed by (id, group). Use instead of hand-rolling a request-counting rate limit. |
Import path: github.com/YaCodeDev/GoYaCodeDevUtils/yaratelimit.
Fixed-window rate limiter backed by any yacache.Cache, keyed by (id uint64, group string).
RateLimiter interface — CheckBanned, Refresh, Increment, Get.RateLimit[Cache yacache.Container] struct — { Cache, Limit uint8, Rate time.Duration }; NewRateLimit[Cache](cache yacache.Cache[Cache], limit uint8, rate time.Duration) *RateLimit[Cache].Storage struct — { Limit uint8 (current count), FirstRequest int64 }.FormatKey(id uint64, group string) string, FormatValue(limit uint8, firstRequest int64) string.Increment(ctx, id, group) returns banned bool = true once the count reaches/exceeds Limit within the current Rate-duration window; the window resets automatically once Rate has elapsed since the first hit.CheckBanned is a read-only pre-check (does not increment) — use it before an expensive operation, then call Increment to record the attempt.yacache + yaerrors. Storage value is a raw CSV string "<count>,<first_unix_sec>" cached at key "rate-limit-<id>-<group>" with no TTL — staleness comes from the window logic, not cache expiry.