SitePen / dstore

A data infrastructure framework, providing the tools for modelling and interacting with data collections and objects.
http://dstorejs.io/
Other
281 stars 83 forks source link

Cache dont work with Rest when it use fetch with range #95

Open akaJes opened 9 years ago

akaJes commented 9 years ago

when you explicite set to Collection creation canCacheQuery:true, than slowly scroll grid to end and back You can see network activity in devTools instead using a cache maybe cache for ranging fetch must configurate another way?

used for tests https://github.com/SitePen/dgrid/blob/master/test/Rest.html with canCacheQuery:true, inserted https://github.com/SitePen/dgrid/blob/master/test/Rest.html#L44 I explored the code and realized that the variable allLoaded is not set ever for fetch with range

EToreo commented 9 years ago

I am trying to Cache the results of a Rest store so a dijit Filtering Select doens't continue to hit the server every time a user drops down the combo box. Even after setting canCacheQuery: true and isValidFetchCache: true the Rest store continues to hit the server. isAvailableInCache() returns undefined no matter how I set things up.

Any ideas on how to get this to work?

// GenericItemStore
define([
      "dojo/_base/declare",
      "dstore/Rest",
      "dstore/Cache",
      "dstore/Memory"
   ],
   function(declare, Rest, Cache, Memory){
      return declare([Rest, Cache], {
         isValidFetchCache:   true,
         canCacheQuery:       true
     });
});

// Filtering Select Gadget
define([
      "dojo/_base/declare",
      "dijit/form/FilteringSelect",
      "dstore/legacy/DstoreAdapter",
      "ts/store/GenericItemStore"
   ],
   function(declare, FilteringSelect, DstoreAdapter, GenericItemStore){
      return declare([FilteringSelect], {
         style:            "width:100%",
         allowAllOption:   false,
         searchAttr:       'Name',
         labelAttr:        '_label',
         labelType:        'html',
         constructor: function(args)
         {
            // Call Super
            dojo.safeMixin(this, args);

            var store = new GenericItemStore({
               target: '/Stores/Employees'
            });

            this.store = new DstoreAdapter(store.filter({includeAll: 'true', includeBlankOption: 'true'}));
         }
     });
});