13 lines
391 B
JavaScript
13 lines
391 B
JavaScript
const Controller = require('egg').Controller;
|
|
|
|
class RedisTestController extends Controller {
|
|
async index() {
|
|
const { app } = this;
|
|
// 测试 Redis 连接
|
|
const result = await app.redis.set('test_key', 'Hello, Redis!');
|
|
const value = await app.redis.get('test_key');
|
|
this.ctx.body = `Redis 测试成功,值为:${value}`;
|
|
}
|
|
}
|
|
|
|
module.exports = RedisTestController; |