Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hapinessjs/redis-module
Redis client module for Hapiness framework
https://github.com/hapinessjs/redis-module
Last synced: 7 days ago
JSON representation
Redis client module for Hapiness framework
- Host: GitHub
- URL: https://github.com/hapinessjs/redis-module
- Owner: hapinessjs
- License: mit
- Created: 2017-07-12T10:22:27.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-03T09:19:14.000Z (about 6 years ago)
- Last Synced: 2024-12-08T06:46:20.699Z (30 days ago)
- Language: TypeScript
- Size: 146 KB
- Stars: 1
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Redis Module
```Redis``` module for the Hapiness framework.
## Table of contents
* [Using your module inside Hapiness application](#using-your-module-inside-hapiness-application)
* [`yarn` or `npm` it in your `package.json`](#yarn-or-npm-it-in-your-package)
* [Importing `RedisModule` from the library](#importing-redismodule-from-the-library)
* [Using `Redis` inside your application](#using-redis-inside-your-application)
* [```RedisClientService``` functions](#redisclientservice-functions)## Using your module inside Hapiness application
### `yarn` or `npm` it in your `package.json`
```bash
$ npm install --save @hapiness/core @hapiness/redis rxjsor
$ yarn add @hapiness/core @hapiness/redis rxjs
``````javascript
"dependencies": {
"@hapiness/core": "^1.3.0",
"@hapiness/redis": "^1.0.1",
"rxjs": "^5.5.5",
//...
}
//...
```### Importing `RedisModule` from the library
This module provide an Hapiness extension for Redis.
To use it, simply register it during the ```bootstrap``` step of your project and provide the ```RedisExt``` with its config```javascript
@HapinessModule({
version: '1.0.0',
providers: [],
declarations: [],
imports: [RedisModule]
})
class MyApp implements OnStart {
constructor() {}
onStart() {}
}Hapiness
.bootstrap(
MyApp,
[
/* ... */
RedisExt.setConfig(
{
url: '//redis_url:6379',
password: 'password',
db: '1'
/* ... Other options ... */
}
)
]
)
.catch(err => {
/* ... */
});```
```RedisExt``` needs a ```ClientOpts``` object so you can provide all the properties defined in the interface (see below)
```
export interface ClientOpts {host?: string;
port?: number;
path?: string;
url?: string;
parser?: string;
string_numbers?: boolean;
return_buffers?: boolean;
detect_buffers?: boolean;
socket_keepalive?: boolean;
no_ready_check?: boolean;
enable_offline_queue?: boolean;
retry_max_delay?: number;
connect_timeout?: number;
max_attempts?: number;
retry_unfulfilled_commands?: boolean;
auth_pass?: string;
password?: string;
db?: string;
family?: string;
rename_commands?: { [command: string]: string };
tls?: any;
prefix?: string;
retry_strategy?: RetryStrategy;
ping_keepalive_interval?: number: // In seconds
}```
### Using `Redis` inside your application
To use redis, you need to inject inside your providers the ```RedisClientService```.
```javascript
class FooProvider {
constructor(private _redis: RedisClientService) {}
bar(): Observable {
return this._redis.connection.get('my_key');
}}
```
## ```RedisClientService``` functions
```RedisClientService.connection``` this will return you the redis client and you will be able to call on it every redis command (see the list of commands [here](https://redis.io/commands))
**INFO** All function returns RxJS Observable
[Back to top](#table-of-contents)
## Maintainers
Julien Fauville
Antoine Gomez
Sébastien Ritz
Nicolas Jessel
[Back to top](#table-of-contents)
## License
Copyright (c) 2017 **Hapiness** Licensed under the [MIT license](https://github.com/hapinessjs/redis-module/blob/master/LICENSE.md).
[Back to top](#table-of-contents)