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

ReferenceError: DSBinaryHeap is not defined when trying to configure a simple sessionStorage based cache. #105

Closed shyam-habarakada closed 10 years ago

shyam-habarakada commented 10 years ago
ReferenceError: DSBinaryHeap is not defined
  at new DSCache (http://localhost:3001/assets/angular-cache/angular-cache.js?body=1:554:27)
  at DSCacheFactory (http://localhost:3001/assets/angular-cache/angular-cache.js?body=1:1741:22)
  at Object.<anonymous> (http://localhost:3001/assets/ng/services/session.js?body=1:7:22)

The code in question looks like

angular.module('app.services').factory('sessionService', [
  '$http', '$log', 'DSCacheFactory', function($http, $log, DSCacheFactory) {

    // ...

    sessionCache = DSCacheFactory('sessionCache', {
      storageMode: 'sessionStorage'
    });

    // ...
    return sessionService;
  }
]);

And my app.services module has a dependency on 'angular-data.DSCacheFactory'

jmdobry commented 10 years ago

@shyam-habarakada Well, thanks for trying out the 3.0.0 beta. I'll take a look!

jmdobry commented 10 years ago

@shyam-habarakada Should be fixed in 3.0.0-beta.2

shyam-habarakada commented 10 years ago

Great, thanks. I will try it out. What's the general status of the beta? We're writing a new app and would like to just use 3.0 if core functionality is stable. We will mainly use session and memory caching (no local storage)

jmdobry commented 10 years ago

@shyam-habarakada I'd like to say that core functionality is stable, but I just released the beta yesterday, so take my assertion of stability with a grain of salt. If however, you still just want to use start using 3.x.x, I am prepared to fix any new bugs as fast as possible.

dbush3721 commented 10 years ago

angular.module('mmar', ['angular-data.DSCacheFactory' ... ... .run(function ($angularCacheFactory) { var myCache = $angularCacheFactory('myCache', { storageMode: 'localStorage' }); })

Uncaught Error: Unknown provider: $angularCacheFactoryProvider <- $angularCacheFactory

Using 3.0 I know $angularCacheFactory is probably incorrect but, I can't figure what it should be? Think its supposed to be DSCacheFactory?

Thanks, Dan

jmdobry commented 10 years ago

If you're on 3.x.x, change $angularCacheFactory to DSCacheFactory and it will work

dbush3721 commented 10 years ago
GcdService.$inject = ['$rootScope', '$q', 'DSCacheFactory', 'loginService', 'dummyLoginService','rulesFile', '$filter'];
function GcdService($rootScope, $q, DSCacheFactory, loginService, dummyLoginService,rulesFile, $filter) {

var gcdCache = DSCacheFactory('gcdCache', { storageMode: 'localStorage' });

...

Error: Unknown provider: $rootElementProvider <- $rootElement <- $location

jmdobry commented 10 years ago

@dbush3721 DSCacheFactory does not depend on the $location service at all. One of those other dependencies must be the problem.