You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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); }); });
The text was updated successfully, but these errors were encountered:
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?
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);
});
});
The text was updated successfully, but these errors were encountered: