windows 7 install and use

code:
config.default.js:

plugin.js:

app.controller.home.js:

then request:

node 7.7.2

不使用cluster模式不要配置到node里,而且要配置到client下。请参考 https://github.com/eggjs/egg-redis/blob/master/config/config.default.js

改成这样还是不行
exports.redis = {
client: {
host: '127.0.0.1',
port: 6379,
password: '',
db: '0',
},
agent:true
};
'use strict';
const path = require('path');
module.exports = appInfo => {
const config = {
mysql : {
// database configuration
client: {
// host
host: 'localhost',
// port
port: '3306',
// username
user: 'root',
// password
password: 'root',
// database
database: 'test',
},
// load into app, default is open
app: true,
// load into agent, default is close
agent: false,
},
redis : {
// database configuration
default: {
// host
host: '127.0.0.1',
// port
port: '6379',
},
// load into app, default is open
app: true,
// load into agent, default is close
agent: false,
},
};
// should change to your own
config.keys = appInfo.name + '_1489048554806_6546';
return config;
};
mysql都没问题
add
password: '',
db: '0',
success
@jtyjty99999 thx
egg-redis app.redis.set is not a function 还是有这个问题,请问是怎么解决的?
配置问题吧,一定得有client or clients
要把 sessionRedis的name配置为空或者不配置
config.sessionRedis = {
name: '', //
}
因为 egg-session-redis/app.js 里的头两行代码是这样的
const name = app.config.sessionRedis.name;
const redis = name ? app.redis.get(name) : app.redis;
一个redis实例, sessionRedis配置中不需要指定实例名,即
config.redis = {
client: {
host: '127.0.0.1',
port: 6379,
password: '',
db: '0',
},
};
config.sessionRedis = {
// name: 'session', // 这里不要指定name
};
如果redis有多个实例,sessionRedis配置中的name需要指定一个实例名
config.redis = {
clients: {
foo: { // instanceName. See below
port: 6379, // Redis port
host: '127.0.0.1', // Redis host
password: 'auth',
db: 0,
},
bar: {
port: 6379,
host: '127.0.0.1',
password: 'auth',
db: 1,
},
}
config.sessionRedis = {
name: 'foo',
};
看源码就知道了: https://github.com/eggjs/egg-session-redis/blob/master/app.js#L9
Most helpful comment