Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Redis as cache #31

Open
ghost opened this issue Jun 16, 2015 · 1 comment
Open

Using Redis as cache #31

ghost opened this issue Jun 16, 2015 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 16, 2015

I am using requestify to call a query endpoint by posting SQL Queries.
I set up Redis to be the cache store.
I want Redis to cache each different query response alone, but instead it is only setting one entry for all the queries with the QUERIES_API_URL as key.
How do I configure Redis/Requestify to make an entry in the cache for each query?
var _redis = require("redis");
var client = _redis.createClient();
var requestify = require('requestify');
requestify.redis(client);

app.get('/api/requests/all',function(req, res, next){
var sql_query="SELECT count(*) as requests ";
var postData = {
"sql": sql_query
}
var options = {
method: 'POST',
body: postData,
headers: {
'Authorization': baseOuth ,
'Content-Type': 'application/json',
'Accept-Charset': 'utf-8'
},
dataType: 'json',
cache:{
cache: true, // Will set caching to true for this request.
expires: 360000 // Time for cache to expire in seconds
}
} ;
requestify.request(QUERIES_API_URL, options).then(function(response) {
var body=response.getBody();
var total=body.results[0][0];
res.send(total);
});
});

@angelxmoreno
Copy link

Late reply but I'll chime in since I recently had a similar issue. First off, according to the README only GET requests are cached. Are you confirming that your POST requests are being cached by actually looking at your Redis server?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant