Drivers
Depending on your use-case storage and performance requirements, you can use different drivers.
Memory
Mainly useful when you want fast access for limited amount of cached data. Use this driver for high-frequency RPC calls.
erpc.yaml
database:
evmJsonRpcCache:
connectors:
- id: memory-cache
driver: memory
memory:
maxItems: 10000
Redis
Redis is useful when you need to store cached data temporarily with eviction policy (e.g. certain amount of memory).
erpc.yaml
database:
evmJsonRpcCache:
connectors:
- id: redis-cache
driver: redis
redis:
addr: YOUR_REDIS_ADDRESS_HERE
password: YOUR_REDIS_PASSWORD_HERE
db: XXX
connPoolSize: 128
Example of Redis config with eviction policy:
maxmemory 2000mb
maxmemory-policy allkeys-lru
PostgreSQL
Useful when you need to store cached data permanently without TTL i.e. forever.
You don't need to create the table, the driver will automatically create the table and requried indexes.
erpc.yaml
database:
evmJsonRpcCache:
connectors:
- id: postgres-cache
driver: postgresql
postgresql:
connectionUri: >-
postgres://YOUR_USERNAME_HERE:YOUR_PASSWORD_HERE@your.postgres.hostname.here.com:5432/your_database_name
table: rpc_cache
DynamoDB
When you need to have scalable (compared to Postgres) permanent caching and are happy with the costs.
erpc.yaml
database:
evmJsonRpcCache:
connectors:
- id: dynamodb-cache
driver: dynamodb
dynamodb:
table: rpc_cache
region: eu-west-1
endpoint: https://dynamodb.eu-west-1.amazonaws.com # Optional
# Auth is optional if you are running within AWS.
auth:
mode: secret # file, or env
accessKeyId: YOUR_ACCESS_KEY_ID # Only if mode is secret
secretAccessKey: YOUR_SECRET_ACCESS_KEY # Only if mode is secret
profile: xxxxx # Only if mode is file
credentialsFile: xxxx # Only if mode is file