Design a system that enforces ad frequency caps, such as:
A user should see campaign X at most N times within a given time window.
The system is used by an ad-serving platform. Before serving an ad, the ad server needs to quickly check whether the user is still eligible to see a candidate campaign. After an impression is actually shown, the system records the event and updates counters.