403Webshell
Server IP : 185.208.173.17  /  Your IP : 87.236.161.98
Web Server : Microsoft-IIS/10.0
System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64
User : IUSR ( 0)
PHP Version : 7.4.13
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/inetpub/wwwroot/parsmega.nuxt/node_modules/cache-manager/examples/redis_example/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/inetpub/wwwroot/parsmega.nuxt/node_modules/cache-manager/examples/redis_example/redis_store.js
/**
 * This is a very basic example of how you can implement your own Redis-based
 * cache store with connection pooling.
 */

var RedisPool = require('sol-redis-pool');

function redisStore(args) {
    args = args || {};
    var self = {};
    var ttlDefault = args.ttl;
    self.name = 'redis';

    var redisOptions = {
        host: args.host || '127.0.0.1',
        port: args.port || 6379
    };

    var pool = new RedisPool(redisOptions, {});

    function connect(cb) {
        pool.acquire(function(err, conn) {
            if (err) {
                pool.release(conn);
                return cb(err);
            }

            if (args.db || args.db === 0) {
                conn.select(args.db);
            }

            cb(null, conn);
        });
    }

    function handleResponse(conn, cb, opts) {
        opts = opts || {};

        return function(err, result) {
            pool.release(conn);

            if (err) { return cb(err); }

            if (opts.parse) {
                result = JSON.parse(result);
            }

            cb(null, result);
        };
    }

    self.get = function(key, options, cb) {
        if (typeof options === 'function') {
            cb = options;
        }

        connect(function(err, conn) {
            if (err) { return cb(err); }
            conn.get(key, handleResponse(conn, cb, {parse: true}));
        });
    };

    self.set = function(key, value, options, cb) {
        if (typeof options === 'function') {
            cb = options;
            options = {};
        }
        options = options || {};

        var ttl = (options.ttl || options.ttl === 0) ? options.ttl : ttlDefault;

        connect(function(err, conn) {
            if (err) { return cb(err); }
            var val = JSON.stringify(value);

            if (ttl) {
                conn.setex(key, ttl, val, handleResponse(conn, cb));
            } else {
                conn.set(key, val, handleResponse(conn, cb));
            }
        });
    };

    self.del = function(key, options, cb) {
        if (typeof options === 'function') {
            cb = options;
        }
        connect(function(err, conn) {
            if (err) { return cb(err); }
            conn.del(key, handleResponse(conn, cb));
        });
    };

    self.ttl = function(key, cb) {
        connect(function(err, conn) {
            if (err) { return cb(err); }
            conn.ttl(key, handleResponse(conn, cb));
        });
    };

    self.keys = function(pattern, cb) {
        if (typeof pattern === 'function') {
            cb = pattern;
            pattern = '*';
        }

        connect(function(err, conn) {
            if (err) { return cb(err); }
            conn.keys(pattern, handleResponse(conn, cb));
        });
    };

    self.isCacheableValue = function(value) {
        return value !== null && value !== undefined;
    };

    return self;
}

module.exports = {
    create: function(args) {
        return redisStore(args);
    }
};

Youez - 2016 - github.com/yon3zu
LinuXploit