This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| App::error(function(Exception $exception, $code) | |
| { | |
| $qs = @Input::all(); | |
| statsWrite::logError($exception,$qs); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Memcached = require('memcached'); | |
| var memcached = new Memcached('memcacheserver:11211'); | |
| var Cache = {} | |
| Cache.add = function (key, value, lifetime) { | |
| memcached.set(key, value, lifetime); | |
| }; | |
| Cache.get = function (key) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cache.get = function (key) { | |
| memcached.get(key, function (err, data) { | |
| console.log(data); | |
| }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cache.add = function (key, value, lifetime) { | |
| memcached.set(key, value, lifetime, function (err){ | |
| if (err) console.warn(err) | |
| });; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Memcached = require('memcached'); | |
| const memcached = new Memcached('server.com:11211'); | |
| memcached.on('issue', details => console.log('issue: ', details)) | |
| memcached.on('failure', details => console.log('failure: ', details)) | |
| memcached.on('reconnecting', details => console.log('reconnecting: ', details)) | |
| memcached.on('reconnect', details => console.log('reconnect: ', details)) | |
| memcached.on('remove', details => console.log('remove: ', details)) | |
| const Cache = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cache.remember = function (key, lifetime, callback) { | |
| memcached.get(key, function (err, data) { | |
| if(data){ | |
| return data; | |
| } | |
| }); | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cache.remember = function (key, lifetime, callback) { | |
| return Promise.try(() => { | |
| return memcached.getAsync(key); | |
| }).then((value) => { | |
| if (value !== undefined) { | |
| return value; | |
| } else { | |
| return Promise.try(() => { | |
| return callback() | |
| }).then((value) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val = cache.remember('key','value1',600,function(){ | |
| return 'value2'; | |
| }); | |
| console.log('set: '+val) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cache.remember = function (key, lifetime, callback) { | |
| return Promise.try(() => { | |
| return memcached.getAsync(key); | |
| }).then((value) => { | |
| if (value !== undefined) { | |
| console.log('exists'); | |
| return value; | |
| } else { | |
| return Promise.try(() => { | |
| if (typeof callback === "function") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mysql.MobileAction.findOne({ where: {action_id: req.query.D} }).then(function(action) { | |
| cache.remember('key1', 600, function() { | |
| return Promise.resolve(action); | |
| }).then((val) => { | |
| console.log('set: ', val); | |
| }) | |
| }) |
OlderNewer