Skip to content

Commit df7741c

Browse files
committed
DSCacheFactory integration complete.
1 parent c57ce9d commit df7741c

File tree

8 files changed

+135
-14
lines changed

8 files changed

+135
-14
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
##### 0.9.0 - xx May 2014
2+
3+
###### Backwards compatible API changes
4+
- #30, #48 - DSCacheFactory integration
5+
16
##### 0.8.1 - 02 May 2014
27

38
###### Backwards compatible Bug fixes

bower.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"author": "Jason Dobry",
33
"name": "angular-data",
44
"description": "Data store for Angular.js.",
5-
"version": "0.8.1",
6-
"homepage": "http://jmdobry.github.io/angular-data/",
5+
"version": "0.9.0-SNAPSHOT",
6+
"homepage": "http://angular-data.codetrain.io/",
77
"repository": {
88
"type": "git",
99
"url": "git://github.com/jmdobry/angular-data.git"

dist/angular-data.js

+29-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* @author Jason Dobry <[email protected]>
3+
* @file angular-data.js
4+
* @version 0.9.0-SNAPSHOT - Homepage <http://angular-data.codetrain.io/>
5+
* @copyright (c) 2014 Jason Dobry <https://github.com/jmdobry/>
6+
* @license MIT <https://github.com/jmdobry/angular-data/blob/master/LICENSE>
7+
*
8+
* @overview Data store for Angular.js.
9+
*/
110
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"QYwGEY":[function(require,module,exports){
211
(function (global){
312
// Copyright 2012 Google Inc.
@@ -2718,7 +2727,23 @@ function defineResource(definition) {
27182727
Resource.prototype = this.defaults;
27192728
this.definitions[definition.name] = new Resource(this.utils, definition);
27202729

2721-
var cache = this.cacheFactory('DS.' + definition.name);
2730+
var _this = this;
2731+
2732+
var cache = this.cacheFactory('DS.' + definition.name, {
2733+
maxAge: definition.maxAge || null,
2734+
recycleFreq: definition.recycleFreq || 1000,
2735+
cacheFlushInterval: definition.cacheFlushInterval || null,
2736+
deleteOnExpire: definition.deleteOnExpire || 'none',
2737+
onExpire: function (id) {
2738+
_this.eject(definition.name, id);
2739+
},
2740+
capacity: Number.MAX_VALUE,
2741+
storageMode: 'memory',
2742+
storageImpl: null,
2743+
disabled: false,
2744+
storagePrefix: 'DS.' + definition.name
2745+
});
2746+
27222747
this.store[definition.name] = {
27232748
collection: [],
27242749
completedQueries: {},
@@ -3874,7 +3899,7 @@ module.exports = [function () {
38743899
* @id angular-data
38753900
* @name angular-data
38763901
* @description
3877-
* __Version:__ 0.8.1
3902+
* __Version:__ 0.9.0-SNAPSHOT
38783903
*
38793904
* ## Install
38803905
*
@@ -3893,7 +3918,7 @@ module.exports = [function () {
38933918
* Load `dist/angular-data.js` or `dist/angular-data.min.js` onto your web page after Angular.js.
38943919
*
38953920
* #### Manual download
3896-
* Download angular-data.0.8.1.js from the [Releases](https://github.com/jmdobry/angular-data/releases)
3921+
* Download angular-data.0.9.0-SNAPSHOT.js from the [Releases](https://github.com/jmdobry/angular-data/releases)
38973922
* section of the angular-data GitHub project.
38983923
*
38993924
* ## Load into Angular
@@ -4030,4 +4055,4 @@ module.exports = [function () {
40304055
};
40314056
}];
40324057

4033-
},{"mout/array/contains":3,"mout/array/filter":4,"mout/array/slice":7,"mout/array/sort":8,"mout/array/toLookup":9,"mout/lang/isEmpty":14,"mout/object/deepMixIn":21,"mout/object/forOwn":23,"mout/object/pick":25,"mout/string/makePath":26,"mout/string/upperCase":27}]},{},[53])
4058+
},{"mout/array/contains":3,"mout/array/filter":4,"mout/array/slice":7,"mout/array/sort":8,"mout/array/toLookup":9,"mout/lang/isEmpty":14,"mout/object/deepMixIn":21,"mout/object/forOwn":23,"mout/object/pick":25,"mout/string/makePath":26,"mout/string/upperCase":27}]},{},[53])

dist/angular-data.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

guide/nav.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<i class="icon-wrench icon-white"></i> API <b class="caret"></b>
5959
</a>
6060
<ul class="dropdown-menu">
61-
<li class="nav-header">Angular-data - 0.7.0</li>
61+
<li class="nav-header">Angular-data - 0.9.0</li>
6262
<li>
6363
<a href="/documentation/api/angular-data">API Index</a>
6464
</li>
@@ -78,7 +78,7 @@
7878
<a href="/documentation/api/angular-data/DSErrors">DSErrors</a>
7979
</li>
8080
<li class="divider"></li>
81-
<li class="nav-header">Angular-cache - 3.0.0-beta.1</li>
81+
<li class="nav-header">Angular-cache - 3.0.0-beta.4</li>
8282
<li>
8383
<a href="/documentation/api/angular-cache">API Index</a>
8484
</li>

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "angular-data",
33
"description": "Data store for Angular.js.",
4-
"version": "0.8.1",
5-
"homepage": "http://github.com/jmdobry/angular-data",
4+
"version": "0.9.0-SNAPSHOT",
5+
"homepage": "http://angular-data.codetrain.io",
66
"repository": {
77
"type": "git",
88
"url": "git://github.com/jmdobry/angular-data.git"

src/datastore/sync_methods/defineResource/index.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,23 @@ function defineResource(definition) {
8282
Resource.prototype = this.defaults;
8383
this.definitions[definition.name] = new Resource(this.utils, definition);
8484

85-
var cache = this.cacheFactory('DS.' + definition.name);
85+
var _this = this;
86+
87+
var cache = this.cacheFactory('DS.' + definition.name, {
88+
maxAge: definition.maxAge || null,
89+
recycleFreq: definition.recycleFreq || 1000,
90+
cacheFlushInterval: definition.cacheFlushInterval || null,
91+
deleteOnExpire: definition.deleteOnExpire || 'none',
92+
onExpire: function (id) {
93+
_this.eject(definition.name, id);
94+
},
95+
capacity: Number.MAX_VALUE,
96+
storageMode: 'memory',
97+
storageImpl: null,
98+
disabled: false,
99+
storagePrefix: 'DS.' + definition.name
100+
});
101+
86102
this.store[definition.name] = {
87103
collection: [],
88104
completedQueries: {},

test/integration/datastore/async_methods/find/index.test.js

+75
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,81 @@ describe('DS.find(resourceName, id[, options]): ', function () {
7575

7676
$httpBackend.flush();
7777
});
78+
it('should get an item from the server and delete when using DSCacheFactory in passive mode', function (done) {
79+
DS.defineResource({
80+
name: 'comment',
81+
endpoint: '/comments',
82+
deleteOnExpire: 'passive',
83+
maxAge: 20
84+
});
85+
86+
$httpBackend.expectGET('http://test.angular-cache.com/comments/5').respond(200, {
87+
id: 5,
88+
text: 'test'
89+
});
90+
91+
DS.find('comment', 5).then(function (comment) {
92+
assert.deepEqual(comment, {
93+
id: 5,
94+
text: 'test'
95+
});
96+
}, function (err) {
97+
console.error(err.stack);
98+
fail('Should not have rejected!');
99+
});
100+
101+
$httpBackend.flush();
102+
103+
assert.deepEqual(DS.get('comment', 5), {
104+
id: 5,
105+
text: 'test'
106+
}, 'The comment is now in the store');
107+
assert.isNumber(DS.lastModified('comment', 5));
108+
assert.isNumber(DS.lastSaved('comment', 5));
109+
110+
setTimeout(function () {
111+
assert.isUndefined(DS.get('comment', 5));
112+
done();
113+
}, 100);
114+
});
115+
it('should get an item from the server and delete when using DSCacheFactory in aggressive mode', function (done) {
116+
DS.defineResource({
117+
name: 'comment',
118+
endpoint: '/comments',
119+
deleteOnExpire: 'aggressive',
120+
recycleFreq: 10,
121+
maxAge: 20
122+
});
123+
124+
$httpBackend.expectGET('http://test.angular-cache.com/comments/5').respond(200, {
125+
id: 5,
126+
text: 'test'
127+
});
128+
129+
DS.find('comment', 5).then(function (comment) {
130+
assert.deepEqual(comment, {
131+
id: 5,
132+
text: 'test'
133+
});
134+
}, function (err) {
135+
console.error(err.stack);
136+
fail('Should not have rejected!');
137+
});
138+
139+
$httpBackend.flush();
140+
141+
assert.deepEqual(DS.get('comment', 5), {
142+
id: 5,
143+
text: 'test'
144+
}, 'The comment is now in the store');
145+
assert.isNumber(DS.lastModified('comment', 5));
146+
assert.isNumber(DS.lastSaved('comment', 5));
147+
148+
setTimeout(function () {
149+
assert.isUndefined(DS.get('comment', 5));
150+
done();
151+
}, 100);
152+
});
78153
it('should get an item from the server but not store it if cacheResponse is false', function () {
79154
$httpBackend.expectGET('http://test.angular-cache.com/posts/5').respond(200, p1);
80155

0 commit comments

Comments
 (0)