Permalink
Browse files

document event emitter cache

  • Loading branch information...
poelzi committed Sep 15, 2011
1 parent 1fdda86 commit 828acd34018778df5e0d298dca33aa94a51100ce
Showing with 12 additions and 2 deletions.
  1. +12 −2 README.md
View
@@ -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.
@@ -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
--------------
@@ -132,6 +140,7 @@ fc = new Flexcache(backend, {
rcached = fc.cache(slow, {
group: function() { return self.somevalue },
name: "somethinguniqe"
emitter: function() { return new MyEventemitter() },
});
@@ -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,...])

0 comments on commit 828acd3

Please sign in to comment.