Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chakrit/redis-wrapper
Provides a simple class/mixin as base for when you need to wraps a redis client (or provide API that does) via a use() method
https://github.com/chakrit/redis-wrapper
Last synced: about 20 hours ago
JSON representation
Provides a simple class/mixin as base for when you need to wraps a redis client (or provide API that does) via a use() method
- Host: GitHub
- URL: https://github.com/chakrit/redis-wrapper
- Owner: chakrit
- Created: 2012-11-09T11:11:34.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2013-03-06T11:09:33.000Z (over 11 years ago)
- Last Synced: 2024-04-15T12:21:33.887Z (7 months ago)
- Language: CoffeeScript
- Homepage:
- Size: 125 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# REDIS-WRAPPER
Because I wrote this too many times already, I decided to just move it into a small module of its own.
### SETUP CLASS
Javascript:
```javascript
function MyRedisClass() { }
MyRedisClass.prototype = new require('redis-wrapper')()// or mix into a singleton object with underscore
MySingleton = { func: function() { } };
MySingleton = _.extend(MySingleton, new require('redis-wrapper')());
```Coffeescript:
```coffeescript
class YourClass extends require('redis-wrapper')
```### USAGE
Setup your classes with `use()`
```javascript
MyClass.prototype = new require('redis-wrapper')();var instance = new MyClass()
, client = require('redis').createClient();instance.use(client);
```Adds `ensureClient()` before redis-related methods to ensure a client is set.
```javascript
MyClass.prototype.someMethod = function() {
this.ensureClient();// do things with this.client
};
```That's all.
### TODO
* Adds ability to use a url (via `redis-url`) or host/port combination.
### LICENSE
BSD