Implemented the rate limiting from Redis

- Uses Redis cache to check for current count
- If not present then sets the value based on the database state
- Any Redis errors are swallowed. Cache failures should NOT fail  the request.
This commit is contained in:
Martyn Inglis
2016-11-11 16:47:52 +00:00
parent 6c27f8023e
commit 88f04a46cf
8 changed files with 225 additions and 44 deletions

View File

@@ -0,0 +1,5 @@
from datetime import datetime
def cache_key(service_id):
return "{}-{}-{}".format(str(service_id), datetime.utcnow().strftime("%Y-%m-%d"), "count")