Skip to content

Commit

Permalink
Merge 5cb0f0b into 02a0cc0
Browse files Browse the repository at this point in the history
  • Loading branch information
niekcandaele committed Jun 9, 2020
2 parents 02a0cc0 + 5cb0f0b commit ac932b2
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/controllers/CustomHook/get-custom-hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ module.exports = {

response = response.map(async hook => {
hook.lastResult = await sails.helpers.redis.get(`hooks:${hook.id}:lastResult`);

if (!_.isNull(hook.lastResult) && sails.helpers.etc.isJson(hook.lastResult)) {
hook.lastResult = JSON.parse(hook.lastResult);
}
Expand All @@ -61,6 +60,7 @@ module.exports = {
response = result;
response.lastResult = await sails.helpers.redis.get(`hooks:${response.id}:lastResult`);


if (!_.isNull(response.lastResult) && sails.helpers.etc.isJson(response.lastResult)) {
response.lastResult = JSON.parse(response.lastResult);
}
Expand Down
2 changes: 1 addition & 1 deletion api/helpers/redis/del.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
fn: async function (inputs, exits) {

const datastore = sails.getDatastore('cache');
if (datastore.adapter === 'sails-redis') {
if (datastore.config.adapter === 'sails-redis') {
sails.getDatastore('cache').leaseConnection(function during(redisConnection, proceed) {
redisConnection.del(inputs.keyString, (err, reply) => {
if (err) return proceed(err);
Expand Down
4 changes: 2 additions & 2 deletions api/helpers/redis/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {

fn: async function (inputs, exits) {
const datastore = sails.getDatastore('cache');
if (datastore.adapter === 'sails-redis') {
if (datastore.config.adapter === 'sails-redis') {
sails.getDatastore('cache').leaseConnection(function during(redisConnection, proceed) {
redisConnection.get(inputs.keyString, (err, reply) => {
if (err) return proceed(err);
Expand All @@ -40,7 +40,7 @@ module.exports = {
if (!sails.cache) {
sails.cache = {};
}
return exits.success(sails.cache[inputs.keyString]);
return exits.success(sails.cache[inputs.keyString] ? sails.cache[inputs.keyString] : null);
}

}
Expand Down
2 changes: 1 addition & 1 deletion api/helpers/redis/incr.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {

fn: async function (inputs, exits) {
const datastore = sails.getDatastore('cache');
if (datastore.adapter === 'sails-redis') {
if (datastore.config.adapter === 'sails-redis') {
sails.getDatastore('cache').leaseConnection(function during(redisConnection, proceed) {
redisConnection.incr(inputs.keyString, (err, reply) => {
if (err) return proceed(err);
Expand Down
2 changes: 1 addition & 1 deletion api/helpers/redis/lrange.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {

fn: async function (inputs, exits) {
const datastore = sails.getDatastore('cache');
if (datastore.adapter === 'sails-redis') {
if (datastore.config.adapter === 'sails-redis') {
sails.getDatastore('cache').leaseConnection(function during(redisConnection, proceed) {
redisConnection.lrange(inputs.keyString, inputs.startIndex, inputs.endIndex, (err, reply) => {
if (err) return proceed(err);
Expand Down
2 changes: 1 addition & 1 deletion api/helpers/redis/rpush.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
fn: async function (inputs, exits) {

const datastore = sails.getDatastore('cache');
if (datastore.adapter === 'sails-redis') {
if (datastore.config.adapter === 'sails-redis') {
sails.getDatastore('cache').leaseConnection(function during(redisConnection, proceed) {
redisConnection.rpush(inputs.keyString, inputs.value, (err, reply) => {
if (err) return proceed(err);
Expand Down
2 changes: 1 addition & 1 deletion api/helpers/redis/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = {

fn: async function (inputs, exits) {
const datastore = sails.getDatastore('cache');
if (datastore.adapter === 'sails-redis') {
if (datastore.config.adapter === 'sails-redis') {
if (inputs.ex) {
if (_.isUndefined(inputs.ttl)) {
return exits.error(`When setting ex true you must provide a TTL.`)
Expand Down

0 comments on commit ac932b2

Please sign in to comment.