Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/proxy_server/node_modules/bull/lib/commands/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /**
* Load redis lua scripts.
* The name of the script must have the following format:
*
* cmdName-numKeys.lua
*
* cmdName must be in camel case format.
*
* For example:
* moveToFinish-3.lua
*
*/
'use strict';
const fs = require('fs');
const path = require('path');
const promisify = require('util.promisify'); //TODO in node >= 8 could be removed
const utils = require('../utils');
//TODO node >= 10 could be used require('fs').promises()
const _fs = {
readdirAsync: promisify(fs.readdir),
readFileAsync: promisify(fs.readFile)
};
module.exports = (function() {
let scripts;
return async function(client) {
await utils.isRedisReady(client);
scripts = await (scripts || loadScripts(__dirname));
return scripts.map(({ name, options }) =>
client.defineCommand(name, options)
);
};
})();
async function loadScripts(dir) {
const scriptsDir = await _fs.readdirAsync(dir);
const luaFiles = scriptsDir.filter(file => path.extname(file) === '.lua');
if (luaFiles.length === 0) {
/**
* To prevent unclarified runtime error "updateDelayset is not a function
* @see https://github.com/OptimalBits/bull/issues/920
*/
throw new Error('No .lua files found!');
}
return Promise.all(
luaFiles.map(async file => {
const lua = await _fs.readFileAsync(path.join(dir, file));
const longName = path.basename(file, '.lua');
return {
name: longName.split('-')[0],
options: {
numberOfKeys: parseInt(longName.split('-')[1]),
lua: lua.toString()
}
};
})
);
}
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0447 ]-- |