Skip to content

themost-framework/redis

Repository files navigation

@themost/redis

Most Web Framework Redis Cache Module

@themost/redis implements the usage of Redis as caching strategy of a MOST Web Framework application.

Installation

npm i @themost/redis

Configuration

Add settings/redis configuration section in your application configuration.

    {
        "settings": {
            "redis": {
                "options": {
                    "host": "127.0.0.1",
                    "port": 6379
                },
                "pool": {
                    "min": 2,
                    "max": 25
                }
            }
        }
    }

The sectionredis/options contains options about configuring the connection to the Redis server.

Read more about connect options at ioredis

Connection pooling

@themost/redis uses generic-pool for connection pooling. Configure redis/pool section to set minimum and maximum number of connections to be used.

Read about connection pooling options at generic-pool

Usage

Configure application services to use RedisCacheStrategy as caching service.

{
    "services": [
        {
            "serviceType": "@themost/data#DataCacheStrategy",
            "strategyType": "@themost/redis#RedisCacheStrategy"
        }
    ]
}