Skip to content

Commit

Permalink
document event emitter cache
Browse files Browse the repository at this point in the history
  • Loading branch information
poelzi committed Sep 15, 2011
1 parent 1fdda86 commit 828acd3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions README.md
@@ -1,7 +1,7 @@
flexcache
=======

Flexible cache for async function calls. It is designed for preventing dirty caches more then on speed.
Flexible cache for async function calls and event emitters. It is designed for preventing dirty caches more then on speed.
Different Backends allows you to cover different usecases.


Expand Down Expand Up @@ -112,7 +112,15 @@ fc.clear_all()

Whatever arguments are passed to cached, they are used to compute the subkey and should therefor never hit a wrong
cache entry.


# EventEmitters

The cache function can also generate EventEmitters. You need to specify emitter in which case you will get the eventemitter returned.
If you specify a function all parameters are passed to it.
It is important that the EventEmitter constructed in the emmiter function does no work at all.
Events forwarded and reactet do are `data` and `end`.

The cache is replayed the same way the data is generated by the original function, but every chunk is sent one tick after another.

Advanced Usage
--------------
Expand All @@ -132,6 +140,7 @@ fc = new Flexcache(backend, {
rcached = fc.cache(slow, {
group: function() { return self.somevalue },
name: "somethinguniqe"
emitter: function() { return new MyEventemitter() },
});


Expand Down Expand Up @@ -175,6 +184,7 @@ The returned function has special members which helps you to deal with cache con
- `hash` same as hash. default: **one**
- `name` identifier for hash
- `multi` if set, don't complain about multiple caches sharing the same name
- `emitter` if set the function will return a event emitter and not run the callback. Can my true ( EventEmitter ) or a simple EventEmitter class.


## cache(...).clear\_group([args,...])
Expand Down

0 comments on commit 828acd3

Please sign in to comment.