Last active
August 29, 2015 14:22
-
-
Save cadecairos/1218c4ba12d34c1d9ea8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var db = require('./dbInterface'); | |
exports = function(server, options, done) { | |
server.method('getResource', function(resourceId, next) { | |
db.find({ | |
id: resourceId | |
}, function(err, data) { | |
if(err) { | |
return next(err); | |
} | |
next(null, data); | |
}); | |
}, { | |
// uses the default cache client on the server, unless name is specified. | |
cache: { | |
// expires in 60 seconds | |
expiresIn: 60000, | |
// try to refresh after 30 seconds | |
staleIn: 30000, | |
// if refresh takes longer than 10 seconds, return cached value to client, refresh cached value in the background | |
staleTimeout: 10000 | |
} | |
}); | |
done(); | |
}; | |
exports.attributes = { | |
name: 'add two numbers server method' | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment