Moved cache queue before of the store get function. (up to 2x performance boost).

Hi! This change prevents the cache store from being bursted. I'm getting up to 200% performance boost when using a local redis store, and should be higher with caches located farther.
You can just throw an exception in the work function and check that the
callback function is called only once and that it receives that error.
El dic 18, 2014 8:19 PM, "Bryan Donovan" <notifications@github.com>
escribió:

> In lib/caching.js
> <https://github.com/BryanDonovan/node-cache-manager/pull/18#discussion-diff-22079610>
> :
>
> >              } else {
> > -                self.queues[key] = [cb];
> > -
> > -                work(function () {
> > -                    var work_args = Array.prototype.slice.call(arguments, 0);
> > -                    if (work_args[0]) { // assume first arg is an error
> > -                        self.queues[key].forEach(function (done) {
> > -                            done.call(null, work_args[0]);
> > -                        });
> > -                        delete self.queues[key];
> > +                domain
> > +                .create()
> > +                .on('error', function(err) {
>
> @aletorrado <https://github.com/aletorrado> - Do you know if there's a
> way to get test coverage for this domain error?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/BryanDonovan/node-cache-manager/pull/18/files#r22079610>
> .
>