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/wincloud_gateway/node_modules/strapi-connector-redis/lib/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict'
const redis = require('redis')
const redisWrapper = require('co-redis')
// Default connection object if config is not provided
const defaults = {
host: '127.0.0.1',
port: 6379,
db: '0',
}
module.exports = function (strapi) {
// This is the key we are looking up in connections
const connectionName = 'redis'
function getConnection(connector) {
// Get connections from ./config/environments/**/database.json
const { connections } = strapi.config
// Check if redis connection is defined
if (typeof connections[connectionName] === 'undefined') {
strapi.log.warn(
`(connector:${connectionName}) please provide a valid connection for the redis. Connector is trying to connect with defaults.`
)
}
// Return connection
return connections[connectionName] || { settings: defaults }
}
async function initialize() {
// Get connection
const redisConnection = getConnection()
// Create client
const client = redis.createClient(redisConnection.settings)
// Wrap client with co
const wrappedClient = redisWrapper(client)
// Log connection error
client.on('error', function (error) {
strapi.log.error(
`The ${connectionName} connector could not connect.`,
error
)
})
if (redisConnection.debug) {
strapi.log.info(`${middlewareName} has been initialised.`)
// Log succesful connection
client.on('connect', function () {
strapi.log.info(`${middlewareName} has been connected to Redis server.`)
})
}
// Expose Redis on Strapi instance
strapi.redis = wrappedClient
}
return {
defaults,
initialize,
}
}
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0666 ]-- |