jmdobry / angular-cache

angular-cache is a very useful replacement for the Angular 1 $cacheFactory.
http://jmdobry.github.io/angular-cache
MIT License
1.39k stars 156 forks source link

Create a cache with new operator #186

Closed anasmithiam closed 9 years ago

anasmithiam commented 9 years ago

Hello, I've tried to create a cache using new operator. Something like

var myCache = new CacheFactory('myCache', {
    maxAge: 60000,
    // ...
  });

It seems that everything it's ok but the documentation doesn't use the operator 'new' when calling CacheFactory constructor (neither mentioning it). So, it's correct the use of new CacheFactory(...)?

jmdobry commented 9 years ago

So, it's correct the use of new CacheFactory(...)?

No, it's not. Follow the documentation:

var myCache = CacheFactory('myCache', {
  maxAge: 60000,
  // ...
});

If jshint doesn't like that, then you can do:

var myCache = CacheFactory.createCache('myCache', {
  maxAge: 60000,
  // ...
});