Skip to content

Commit

Permalink
Initial work on cache predictor
Browse files Browse the repository at this point in the history
  • Loading branch information
atruskie committed Dec 13, 2014
1 parent 99c3397 commit 0191447
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/baw.configuration.tpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,32 @@ angular.module('bawApp.configuration', ['url'])
bookmark: {
lastPlaybackPositionName: "Last playback position",
appCategory: "<<application>>"
},
predictiveCache: {

profiles: [
{
name: "Media cache ahead",
match: "some url",
request: ["one url", "another url"],
progression: [
function(data, previous) {
return previous + 30.0;
},
function(data, previous) {
var next = previous + 30.0;
if (next >= data.max) {
return;
}
else {
return next;
}
}
],
count: 10,
method: "HEAD"

}
]
}
});
22 changes: 22 additions & 0 deletions src/components/services/predictiveCache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
angular
.module("bawApp.services.predictiveCache", [])
.factory(
"predictiveCache",
["$http", function ($http) {

var defaults = {
name: null,
match: null,
request: [],
progression: [],
count: 0,
method: "HEAD"
};

return {
addProfile: function predictiveCache(profile) {

}
}
}]
);
40 changes: 40 additions & 0 deletions src/components/services/predictiveCache.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
describe("The predictiveCache service", function () {

var predictiveCache;

beforeEach(module("bawApp.services"));

beforeEach(inject(["predictiveCache", function (_predictiveCache) {
predictiveCache = _predictiveCache;
}]));

var testProfile = {
name: "Media cache ahead",
match: /google\.com\?page=(.*)&skip=(.*)/,
request: ["one url", "another url"],
progression: [
function(data, previous) {
return previous + 30.0;
},
function(data, previous) {
var next = previous + 30.0;
if (next >= data.max) {
return;
}
else {
return next;
}
}
],
count: 10,
method: "HEAD"
};


it("requires an object to function", function() {
expect(function() {
predictiveCache();
}).toThrowError(Error, "A profile is required");

});
});

0 comments on commit 0191447

Please sign in to comment.