import type { HitLimitStore, HitWithBanResult, StoreResult } from '@joint-ops/hitlimit-types'; export interface RedisStoreOptions { url?: string; keyPrefix?: string; } export declare const HIT_SCRIPT = "\nlocal key = KEYS[1]\nlocal windowMs = tonumber(ARGV[1])\nlocal count = redis.call('INCR', key)\nlocal ttl = redis.call('PTTL', key)\nif ttl < 0 then\n redis.call('PEXPIRE', key, windowMs)\n ttl = windowMs\nend\nreturn {count, ttl}\n"; export declare const HIT_WITH_BAN_SCRIPT = "\nlocal hitKey = KEYS[1]\nlocal banKey = KEYS[2]\nlocal violationKey = KEYS[3]\nlocal windowMs = tonumber(ARGV[1])\nlocal limit = tonumber(ARGV[2])\nlocal banThreshold = tonumber(ARGV[3])\nlocal banDurationMs = tonumber(ARGV[4])\n\n-- Check ban first\nlocal banTTL = redis.call('PTTL', banKey)\nif banTTL > 0 then\n return {-1, banTTL, 1, 0}\nend\n\n-- Hit counter\nlocal count = redis.call('INCR', hitKey)\nlocal ttl = redis.call('PTTL', hitKey)\nif ttl < 0 then\n redis.call('PEXPIRE', hitKey, windowMs)\n ttl = windowMs\nend\n\n-- Track violations if over limit\nlocal banned = 0\nlocal violations = 0\nif count > limit then\n violations = redis.call('INCR', violationKey)\n local vTTL = redis.call('PTTL', violationKey)\n if vTTL < 0 then\n redis.call('PEXPIRE', violationKey, banDurationMs)\n end\n if violations >= banThreshold then\n redis.call('SET', banKey, '1', 'PX', banDurationMs)\n banned = 1\n end\nend\nreturn {count, ttl, banned, violations}\n"; export declare class RedisStore implements HitLimitStore { private redis; private prefix; private banPrefix; private violationPrefix; constructor(options?: RedisStoreOptions); hit(key: string, windowMs: number, _limit: number): Promise; hitWithBan(key: string, windowMs: number, limit: number, banThreshold: number, banDurationMs: number): Promise; isBanned(key: string): Promise; ban(key: string, durationMs: number): Promise; recordViolation(key: string, windowMs: number): Promise; reset(key: string): Promise; shutdown(): Promise; } export declare function redisStore(options?: RedisStoreOptions): HitLimitStore; //# sourceMappingURL=redis.d.ts.map