ajax长轮询


redis Demo

// 导包
const redis = require('redis');
// 配置信息
const RDS_PORT = 6379
const RDS_HOST = '127.0.0.1'
const RDS_OPTS = {}
// 连接redis
let client = redis.createClient(RDS_PORT, RDS_HOST, RDS_OPTS)


client.on('ready', () => {
    // console.log(client.values, client)
    // console.log('ready')
})

// 连接成功触发事件 
client.on('connect', () => {
    // client.flushall()
    // 变量存入redis 
    client.set('author0', 'user0', function (q,val) {
        console.log(val, 0)
    })
    client.set('author1', 'user1', function (q, val) {
        console.log(val, 0)
    })
    client.set('author2', 'user2', function (q, val) {
        console.log(val, 0)
    })
    getAllData(client)
    
    // 删除redis key
    client.DEL('author', redis.print)
    client.get('author', redis.print)
})

// 获取所有值
function getAllData(client) {
    client.keys("*", function (err, val) {
        val.forEach(element => {
            client.get(element, function (e, val) {
                console.log(val, 2)
            })
        });
    })
}
                

API参考

redis包Api Redis命令参考

工作人员

 
                    
作者:XXX
信息录入:XXX
文案编辑:XXX
视频录制:XXX
视频编辑:XXX
图片编辑:XXX