forked from actionhero/actionhero
/
cacheTest.js
executable file
·56 lines (50 loc) · 1.3 KB
/
cacheTest.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var action = {};
/////////////////////////////////////////////////////////////////////
// metadata
action.name = "cacheTest";
action.description = "I will test the internal cache functions of the API";
action.inputs = {
"required" : ["key", "value"],
"optional" : []
};
action.outputExample = {
cacheTestResults: {
key: "key",
value: "value",
saveResp: "OK",
loadResp: "OK",
deleteResp: "OK",
}
}
/////////////////////////////////////////////////////////////////////
// functional
action.run = function(api, connection, next)
{
api.utils.requiredParamChecker(api, connection, ["key","value"]);
if(connection.error == false)
{
var key = connection.params.key;
var value = connection.params.value;
connection.response = {cacheTestResults : {
"key" : key,
"value" : value,
}};
api.cache.save(api,key,value,null, function(resp){
connection.response.cacheTestResults.saveResp = resp;
api.cache.load(api,key, function(resp){
connection.response.cacheTestResults.loadResp = resp;
api.cache.destroy(api,key, function(resp){
connection.response.cacheTestResults.deleteResp = resp;
next(connection, true);
});
});
});
}
else
{
next(connection, true);
}
};
/////////////////////////////////////////////////////////////////////
// exports
exports.action = action;