Store Configuration#

1) RedisStore#

RedisStore is developed based on the Redis API provided by redis-py.

In terms of Redis connection configuration management, the configuration naming of django-redis is basically used to reduce the learning cost.

from throttled import store

store.RedisStore(server="redis://127.0.0.1:6379/0", options={"PASSWORD": ""})
from throttled.asyncio import store

store.RedisStore(server="redis://127.0.0.1:6379/0", options={"PASSWORD": ""})

Arguments#

server

Standard Redis URL

"redis://localhost:6379/0"

options

<Options>

{}

Options#

Parameter

Description

Default

CONNECTION_FACTORY_CLASS

ConnectionFactory is used to create and maintain ConnectionPool.

"throttled.store.ConnectionFactory"

CONNECTION_POOL_CLASS

ConnectionPool import path.

"redis.connection.ConnectionPool"

CONNECTION_POOL_KWARGS

ConnectionPool construction parameters.

{}

REDIS_CLIENT_CLASS

RedisClient import path, uses redis.client.Redis by default.

"redis.client.Redis"

REDIS_CLIENT_KWARGS

RedisClient construction parameters.

{}

PASSWORD

Password.

null

SOCKET_TIMEOUT

ConnectionPool parameters.

null

SOCKET_CONNECT_TIMEOUT

ConnectionPool parameters.

null

SENTINELS

(host, port) tuple list, for sentinel mode, please use SentinelConnectionFactory and provide this configuration.

[]

SENTINEL_KWARGS

Sentinel construction parameters.

{}

2) MemoryStore#

MemoryStore is essentially a memory-based LRU Cache with expiration time.

from throttled import store

store.MemoryStore(options={"MAX_SIZE": 10240})
from throttled.asyncio import store

store.MemoryStore(options={"MAX_SIZE": 10240})

Arguments#

options

<Options>

{}

Options#

Parameter

Description

Default

MAX_SIZE

Maximum capacity. When the number of stored key-value pairs exceeds MAX_SIZE, they will be eliminated according to the LRU policy.

1024