# smallorange-redis-client

> Lightweight redis client built on top of RxJS

Latest version **1.0.25** (published 2017-10-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install smallorange-redis-client
pnpm add smallorange-redis-client
yarn add smallorange-redis-client
bun add smallorange-redis-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.25 |
| Published | 2017-10-24 |
| First published | 2017-01-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Felipe Rohde |
| Maintainers | feliperohde |

## Links

- npm: https://www.npmjs.com/package/smallorange-redis-client
- Repository: https://github.com/feliperohdee/smallorange-redis-client
- Homepage: https://smallorange.co
- Issues: https://github.com/feliperohdee/smallorange-redis-client/issues
- npm.io page: https://npm.io/package/smallorange-redis-client

## Dependencies (3)

- [rxjs](https://npm.io/package/rxjs.md) ^5.5.1
- [redis](https://npm.io/package/redis.md) ^2.8.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.4

## Recent versions

- 1.0.25 (latest) — 2017-10-24
- 1.0.24 — 2017-10-24
- 1.0.23 — 2017-10-04
- 1.0.22 — 2017-04-06
- 1.0.21 — 2017-03-24
- 1.0.20 — 2017-03-14
- 1.0.19 — 2017-03-14
- 1.0.18 — 2017-03-01
- 1.0.17 — 2017-02-27
- 1.0.16 — 2017-02-27
- 1.0.15 — 2017-02-27
- 1.0.14 — 2017-02-26
- 1.0.13 — 2017-02-26
- 1.0.12 — 2017-02-12
- 1.0.11 — 2017-02-11
- … 3 more at https://npm.io/package/smallorange-redis-client/versions

## README

[![CircleCI](https://circleci.com/gh/feliperohdee/smallorange-redis-client.svg?style=svg)](https://circleci.com/gh/feliperohdee/smallorange-redis-client)

# Redis client built with lodash and rxjs!

## Compatible with just Node 7 and greater!!!!!!

Hi, this client is built on top of RxJS Observables (a reactive programming library http://reactivex.io/rxjs/), so, would be good to have a small portion of knowledege about that to enjoy all the features which this lib provide, specially the operators. Not all commands were implemented, just the enough to our needs, feel free to do more.

## Properties
		client: RedisClient; // http://npmjs.com/package/redis
		onMessage: Observable<{channel: string, message: any}>
		multi: [tansaction block];

## Methods
		constructor(options?: {
			retryStrategy: function // see https://www.npmjs.com/package/redis#options-object-properties,
			connection: {
				port: number,
				... // see https://www.npmjs.com/package/redis#options-object-properties,
			}
		});

		enableclients(): void; // enable client and subscribe clients
		flush(): void;
		close(): void;
		multiExec(multi: Redis.Multi): Observable<Array<number>>;
		set(key: string, value: string, expires: number = null, replace: boolean = true): Observable<string>;
		get(key: string): Observable<string>;
		keys(pattern: string || Array<string>): Observable<string>;
		ttl(key: string): Observable<number>;
		hashSet(key: string, field: string, value: string = '', expires: number = null, replace: boolean = true): Observable<number>;
		hashDel(key: string, field: string): Observable<number>;
		hashGet(key: string, field: string): Observable<string>;
		hashExists(key: string, field: string): Observable<boolean>;
		hashAll(key: string): Observable<{field: string, value: string}>;
		hashAllLike(key: string, fieldsLike: Array<string> | string): Observable<{field: string, value: string}>;
		hashKeys(key: string): Observable<string>;
		hashKeysLike(key: string, fieldsLike: Array<string> | string): Observable<Array<string>>;
		publish(channel: string, message: any, ignoreSameNode: boolean = true): void;
		onChannel(patternOrChannel: string, usePAttern: boolean = false): Observable<any>;
		sendCommand(command: string, ...args): Observable<string>;
		wrapObservable(clientMethod: function, ...args): Observable<any>;

## Inexistent methods

To implement your own method is simple, follow this sample implementing lpush and lrange:

		import Redis from 'smallorange-redis-client';

		const redis = new Redis();

		function pushList(key, ...values) {
			const op = _.last(values) === true ? ::redis.client.lpush : ::redis.client.rpush;

			op(key, values);
		}

		function listRange(key, start = 0, stop = 0) {
			return redis.wrapObservable(redis.client.lrange, key, start, stop);
		}
		
		pushList('myList', 'a', 'b', 'c');

		listRange('myList', 0, 90)
			.toArray()
			.subscribe(response => {
				expect(response).to.deep.equal(['a', 'b', 'c']);
			}, null, done);

## Sample

		import {
			Redis
		} from 'smallorange-redis-client';

		const redis = new Redis();

		for(let i=0; i<=100, i++){
			redis.hashSet('someKey', `field-${i}`, i);
		}

		redis.hashAll('someKey')
			.filter(response => response.value >= 50)
			.subscribe(console.log); // will print 50x from {field: 'field-50', value: 50} to {field: 'field-100', value: 100}

---
_Source: https://npm.io/package/smallorange-redis-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
