Class AwarenessThrottler

java.lang.Object
net.carcdr.yhocuspocus.redis.AwarenessThrottler

public final class AwarenessThrottler extends Object
Throttles awareness updates to prevent excessive Redis traffic.

Awareness updates (cursor positions, user presence) are high-frequency and can overwhelm Redis with pub/sub messages. This throttler ensures that updates are not published more frequently than the configured interval.

Usage:


 AwarenessThrottler throttler = new AwarenessThrottler(Duration.ofMillis(100));

 // In awareness update handler:
 if (throttler.tryAcquire(documentName)) {
     // Publish awareness update to Redis
 }
 // else: skip this update, it's too soon
 

Thread-safe implementation using ConcurrentHashMap.