-
Notifications
You must be signed in to change notification settings - Fork 6
Multi Instance Cluster (Redis)
Ollie Jennings edited this page Sep 14, 2020
·
3 revisions
Often you will have multiple servers / services interacting with the Riot API, and since the Riot API returns encrypted IDs based on your API Token, you will not be able to use multiple tokens (such as 1 per server). We will want to use the same API Token across all servers, however we need to make sure that each server is aware of the current rate limits imposed by the API. One way of doing this would just be to make the RateLimiter update its current limits on every response, however we can utilise Redis to store our rate-limiters resevoirs and counts, so that they can be shared across servers.
In order to use Redis as a shared global store, we must pass in our Redis
connection details & set datastore
to be ioredis
:
const limiter = new RiotRateLimiter({
redis: 'redis://localhost:6379',
datastore: 'ioredis'
});
// or
const limiter = new RiotRateLimiter({
redis: {
host: 'localhost'.
port: 6379
},
datastore: 'ioredis'
});