You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default Backbone super sync will timeout requests that take longer than 10 seconds. This is to avoid
long hanging requests that can potentionally leak memory. You can set this to be longer for all requests, e.g.
superSync.timeout=60000;// All requests timeout after 1 minute
...or you can set this per-request by specifying it in options, e.g.
At Artsy we naively cache our server-side Backbone.sync requests. You can configure Backbone Super Sync to do this by setting superSync.cacheClient = client. If the cache: true option is set in a model.fetch, Backbone Super Sync will use the cacheClient to cache GET requests. The client API is based off of node-redis but you could easily leverage this API to roll your own caching mechanism.
e.g.
memoryCache={}superSync.cacheClient={set: function(key,val,callback){memoryCache[key]=val;callback(null,'OK');}),get: function(key,callback){callback(null,memoryCache[key]);},expire: function(key,expiresIn,callback){setTimeout(expiresIn/1000,function(){memoryCache[key]=null;callback(null,1);});}}// Cache expiry time. Uses seconds. Defaults to 3600 or 1 hour. You may// also pass `cacheTime: Number` in the options of a fetch to set per-request.superSync.defaultCacheTime=60;newBackbone.Model({id: 'cach-me'}).fetch({cache: true,success: function(){}})
In the past there was a helper superSync.editRequest = function(req) {}. This has been deprecated. If you would like to modify sync-wide requests you can simply wrap Backbone.sync again. For example: