-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
31 lines (24 loc) · 712 Bytes
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var http = require('http');
var Eu = require('eu');
var medea = require('medea');
var MedeaStore = require('./medea_store');
var db = medea();
var store = new MedeaStore(db);
var cache = new Eu.Cache(store, 'test');
var eu = new Eu(cache);
var server = http.createServer(function(req, res) {
var date = new Date();
res.writeHead(200,
{ 'Date': date.toUTCString(), 'Cache-Control': 'max-age=5' });
console.log("Server hit!");
res.end('Hello ' + date);
});
db.open('./.data', function() {
server.listen(3000, function(err) {
setInterval(function() {
eu.get('http://localhost:3000', function(err, res, body) {
console.log("Client: " + body);
});
}, 1000);
});
});