<!-- This file was generated by @travetto/doc and should not be modified directly -->
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/model-redis/DOC.tsx and execute "npx trv doc" to rebuild -->
# Redis Model Support

## Redis backing for the travetto model module.

**Install: @travetto/model-redis**
```bash
npm install @travetto/model-redis

# or

yarn add @travetto/model-redis
```

This module provides an [redis](https://redis.io)-based implementation for the [Data Modeling Support](https://github.com/travetto/travetto/tree/main/module/model#readme "Datastore abstraction for core operations.").  This source allows the [Data Modeling Support](https://github.com/travetto/travetto/tree/main/module/model#readme "Datastore abstraction for core operations.") module to read, write and query against [redis](https://redis.io). 

Supported features:
   *  [CRUD](https://github.com/travetto/travetto/tree/main/module/model/src/types/crud.ts#L11)
   *  [Expiry](https://github.com/travetto/travetto/tree/main/module/model/src/types/expiry.ts#L10)
   *  [Indexed](https://github.com/travetto/travetto/tree/main/module/model/src/types/indexed.ts#L11)

Out of the box, by installing the module, everything should be wired up by default.If you need to customize any aspect of the source or config, you can override and register it with the [Dependency Injection](https://github.com/travetto/travetto/tree/main/module/di#readme "Dependency registration/management and injection support.") module.

**Code: Wiring up a custom Model Source**
```typescript
import { InjectableFactory } from '@travetto/di';
import { type RedisModelConfig, RedisModelService } from '@travetto/model-redis';

export class Init {
  @InjectableFactory({
    primary: true
  })
  static getModelSource(config: RedisModelConfig) {
    return new RedisModelService(config);
  }
}
```

where the [RedisModelConfig](https://github.com/travetto/travetto/tree/main/module/model-redis/src/config.ts#L6) is defined by:

**Code: Structure of RedisModelConfig**
```typescript
@Config('model.redis')
export class RedisModelConfig {
  client: redis.RedisClientOptions = {};
  namespace?: string;
  modifyStorage?: boolean;
}
```

Additionally, you can see that the class is registered with the [@Config](https://github.com/travetto/travetto/tree/main/module/config/src/decorator.ts#L13) annotation, and so these values can be overridden using the standard [Configuration](https://github.com/travetto/travetto/tree/main/module/config#readme "Configuration support") resolution paths.
