cloudcms-server 3.2.283 → 3.2.286
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/broadcast/broadcast.js +6 -3
- package/d1/index.js +629 -0
- package/d1/index.js.works +203 -0
- package/d1/package.json +86 -0
- package/d1/package.json.works +14 -0
- package/index.js +42 -0
- package/launchpad/index.js +60 -31
- package/launchpad/launchers/cluster.js +1 -1
- package/locks/locks.js +4 -2
- package/middleware/awareness/awareness.js +4 -2
- package/middleware/cache/cache.js +4 -2
- package/middleware/cache/providers/shared-memory.js +3 -3
- package/package.json +5 -4
- package/server/index.js +1 -1
- package/util/proxy-factory.js +3 -4
- package/temp/memored/.jshintrc +0 -4
- package/temp/memored/README.md +0 -240
- package/temp/memored/demo/demo1.js +0 -37
- package/temp/memored/demo/demo2.js +0 -32
- package/temp/memored/gulpfile.js +0 -8
- package/temp/memored/index.js +0 -343
- package/temp/memored/package.json +0 -54
- package/temp/memored/spec/memored.spec.js +0 -265
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/* global describe, after, it */
|
|
4
|
-
var cluster = require('cluster'),
|
|
5
|
-
expect = require('chai').expect,
|
|
6
|
-
faker = require('faker'),
|
|
7
|
-
async = require('async'),
|
|
8
|
-
memored = require('../index.js');
|
|
9
|
-
|
|
10
|
-
function _createUser() {
|
|
11
|
-
return {
|
|
12
|
-
firstName: faker.Name.findName(),
|
|
13
|
-
lastName: faker.Name.lastName(),
|
|
14
|
-
email: faker.Internet.email(),
|
|
15
|
-
address: {
|
|
16
|
-
streetAddress: faker.Address.streetName() + ' - ' + faker.Address.streetAddress(),
|
|
17
|
-
zipCode: faker.Address.zipCode(),
|
|
18
|
-
city: faker.Address.city()
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe('Memored test suite', function() {
|
|
24
|
-
|
|
25
|
-
if (cluster.isMaster) {
|
|
26
|
-
cluster.fork();
|
|
27
|
-
|
|
28
|
-
describe('Memored - purge', function() {
|
|
29
|
-
|
|
30
|
-
var mockedData = [
|
|
31
|
-
{
|
|
32
|
-
key: 'mock1',
|
|
33
|
-
value: _createUser(),
|
|
34
|
-
ttl: 25
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
key: 'mock2',
|
|
38
|
-
value: _createUser(),
|
|
39
|
-
ttl: 75
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
key: 'mock3',
|
|
43
|
-
value: _createUser()
|
|
44
|
-
}
|
|
45
|
-
];
|
|
46
|
-
|
|
47
|
-
it.only('Should auto-remove old data if configured to purge', function(done) {
|
|
48
|
-
async.series({
|
|
49
|
-
setup: function(next) {
|
|
50
|
-
memored.setup({purgeInterval: 50, mockData: mockedData});
|
|
51
|
-
next();
|
|
52
|
-
},
|
|
53
|
-
getCacheSize: function(next) {
|
|
54
|
-
memored.size(function(data) {
|
|
55
|
-
expect(data.size).to.equal(3);
|
|
56
|
-
next();
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
wait: function(next) {
|
|
60
|
-
setTimeout(next, 60);
|
|
61
|
-
},
|
|
62
|
-
getCacheSize2: function(next) {
|
|
63
|
-
memored.size(function(data) {
|
|
64
|
-
expect(data.size).to.equal(2);
|
|
65
|
-
next();
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
waitAgain: function(next) {
|
|
69
|
-
setTimeout(next, 50);
|
|
70
|
-
},
|
|
71
|
-
getCacheSize3: function(next) {
|
|
72
|
-
memored.size(function(data) {
|
|
73
|
-
expect(data.size).to.equal(1);
|
|
74
|
-
next();
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
}, done);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
} else {
|
|
82
|
-
|
|
83
|
-
after(function() {
|
|
84
|
-
process.exit();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
describe('Memored - store', function() {
|
|
88
|
-
|
|
89
|
-
it('Should store a value in the cache', function(done) {
|
|
90
|
-
var user1 = _createUser();
|
|
91
|
-
memored.store('user1', user1, function(err, expirationTime) {
|
|
92
|
-
expect(err).to.equal(null);
|
|
93
|
-
expect(expirationTime).to.equal(undefined);
|
|
94
|
-
done();
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('Should store a value and create an expiration time when ttl is used', function(done) {
|
|
99
|
-
var user2 = _createUser(),
|
|
100
|
-
t1 = Date.now();
|
|
101
|
-
memored.store('user2', user2, 100, function(err, expirationTime) {
|
|
102
|
-
expect(err).to.equals(null);
|
|
103
|
-
expect(expirationTime).to.be.a('number');
|
|
104
|
-
expect(expirationTime).to.be.least(t1 + 100);
|
|
105
|
-
done();
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe('Memored - read', function() {
|
|
112
|
-
|
|
113
|
-
it('Should read a cache entry', function(done) {
|
|
114
|
-
var user3 = _createUser();
|
|
115
|
-
async.series({
|
|
116
|
-
storeValue: function(next) {
|
|
117
|
-
memored.store('user3', user3, next);
|
|
118
|
-
},
|
|
119
|
-
readValue: function(next) {
|
|
120
|
-
memored.read('user3', function(err, value) {
|
|
121
|
-
expect(err).to.equals(null);
|
|
122
|
-
expect(value).to.eql(user3);
|
|
123
|
-
next();
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}, done);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('Should return an undefined entry when looking for a non-existing cache entry', function(done) {
|
|
130
|
-
memored.read('unknownKey', function(err, value) {
|
|
131
|
-
expect(err).to.equals(null);
|
|
132
|
-
expect(value).to.equal(undefined);
|
|
133
|
-
done();
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('Should respect cache entry ttl', function(done) {
|
|
138
|
-
var user4 = _createUser(),
|
|
139
|
-
t1 = Date.now();
|
|
140
|
-
|
|
141
|
-
async.series({
|
|
142
|
-
storeValue: function(next) {
|
|
143
|
-
memored.store('user4', user4, 20, next);
|
|
144
|
-
},
|
|
145
|
-
readValue1: function(next) {
|
|
146
|
-
memored.read('user4', function(err, value, expirationTime) {
|
|
147
|
-
expect(err).to.equals(null);
|
|
148
|
-
expect(value).to.eql(user4);
|
|
149
|
-
expect(expirationTime).to.least(t1 + 20);
|
|
150
|
-
next();
|
|
151
|
-
});
|
|
152
|
-
},
|
|
153
|
-
readValue2: function(next) {
|
|
154
|
-
setTimeout(function() {
|
|
155
|
-
memored.read('user4', function(err, value) {
|
|
156
|
-
expect(err).to.equals(null);
|
|
157
|
-
expect(value).to.equal(undefined);
|
|
158
|
-
next();
|
|
159
|
-
});
|
|
160
|
-
}, 30);
|
|
161
|
-
}
|
|
162
|
-
}, done);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
describe('Memored - remove', function() {
|
|
168
|
-
|
|
169
|
-
it('Should remove a cache entry', function(done) {
|
|
170
|
-
var user5 = _createUser();
|
|
171
|
-
async.series({
|
|
172
|
-
storeValue: function(next) {
|
|
173
|
-
memored.store('user5', user5, next);
|
|
174
|
-
},
|
|
175
|
-
readValue1: function(next) {
|
|
176
|
-
memored.read('user5', function(err, value) {
|
|
177
|
-
expect(err).to.equals(null);
|
|
178
|
-
expect(value).to.eql(user5);
|
|
179
|
-
next();
|
|
180
|
-
});
|
|
181
|
-
},
|
|
182
|
-
removeValue: function(next) {
|
|
183
|
-
memored.remove('user5', next);
|
|
184
|
-
},
|
|
185
|
-
readValue2: function(next) {
|
|
186
|
-
memored.read('user5', function(err, value) {
|
|
187
|
-
expect(err).to.equals(null);
|
|
188
|
-
expect(value).to.equal(undefined);
|
|
189
|
-
next();
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}, done);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
describe('Memored - clean', function() {
|
|
198
|
-
it('Should remove all values in cache', function(done) {
|
|
199
|
-
var user6 = _createUser(),
|
|
200
|
-
user7 = _createUser();
|
|
201
|
-
|
|
202
|
-
async.series({
|
|
203
|
-
soreValue1: function(next) {
|
|
204
|
-
memored.store('user6', user6, next);
|
|
205
|
-
},
|
|
206
|
-
storeValue2: function(next) {
|
|
207
|
-
memored.store('user7', user7, next);
|
|
208
|
-
},
|
|
209
|
-
readValue1: function(next) {
|
|
210
|
-
memored.read('user6', function(err, value) {
|
|
211
|
-
expect(err).to.equals(null);
|
|
212
|
-
expect(value).to.eql(user6);
|
|
213
|
-
next();
|
|
214
|
-
});
|
|
215
|
-
},
|
|
216
|
-
readValue2: function(next) {
|
|
217
|
-
memored.read('user7', function(err, value) {
|
|
218
|
-
expect(err).to.equals(null);
|
|
219
|
-
expect(value).to.eql(user7);
|
|
220
|
-
next();
|
|
221
|
-
});
|
|
222
|
-
},
|
|
223
|
-
cleanCache: function(next) {
|
|
224
|
-
memored.clean(next);
|
|
225
|
-
},
|
|
226
|
-
readValue4: function(next) {
|
|
227
|
-
memored.read('user6', function(err, value) {
|
|
228
|
-
expect(err).to.equals(null);
|
|
229
|
-
expect(value).to.equal(undefined);
|
|
230
|
-
next();
|
|
231
|
-
});
|
|
232
|
-
},
|
|
233
|
-
readValue5: function(next) {
|
|
234
|
-
memored.read('user7', function(err, value) {
|
|
235
|
-
expect(err).to.equals(null);
|
|
236
|
-
expect(value).to.equal(undefined);
|
|
237
|
-
next();
|
|
238
|
-
});
|
|
239
|
-
},
|
|
240
|
-
}, done);
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
describe('Memored - setup -- logger', function() {
|
|
245
|
-
var customLogger = {
|
|
246
|
-
messages: [],
|
|
247
|
-
log: function() {
|
|
248
|
-
this.messages.push(Array.prototype.slice.call(arguments).join(','));
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
it('Should use a custom logger when requested', function(done) {
|
|
252
|
-
memored.setup({
|
|
253
|
-
logger: customLogger
|
|
254
|
-
});
|
|
255
|
-
expect(customLogger.messages).to.be.have.length(0);
|
|
256
|
-
memored.store('user8', _createUser(), function() {
|
|
257
|
-
expect(customLogger.messages).to.have.length(1);
|
|
258
|
-
done();
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
});
|