• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ioredis.on函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中ioredis.on函数的典型用法代码示例。如果您正苦于以下问题:TypeScript on函数的具体用法?TypeScript on怎么用?TypeScript on使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了on函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: Promise

const useRedis = new Promise(resolve => {
  redis.on('ready', () => {
    resolve(true);
  });
  redis.on('error', err => {
    resolve(false);
    return redis.quit();
  });
}).then(val => {
开发者ID:WordToken,项目名称:voice-web,代码行数:9,代码来源:lazy-cache.ts


示例2: Redis

const redisHandler = (orm: {skip: boolean, config?: Redis.RedisOptions | string},
                      logger: Logger, callback: (err, ...args) => void) => {
    if (orm.skip) return callback(void 0);

    const cursor = new Redis(orm.config as Redis.RedisOptions);
    cursor.on('error', err => {
        logger.error(`Redis::error event - ${cursor['options']['host']}:${cursor['options']['port']} - ${err}`);
        logger.error(err);
        return callback(err); // TODO: Check if `callback` has been called
    });
    cursor.on('connect', () => {
        logger.info(`Redis client connected to:\t ${cursor['options']['host']}:${cursor['options']['port']}`);
        return callback(void 0, { connection: cursor });
    });
};
开发者ID:SamuelMarks,项目名称:restify-utils,代码行数:15,代码来源:index.ts


示例3: redis

"use strict";

import * as escape from "escape-html";
import * as express from "express";
import { NextFunction } from "express-serve-static-core";
import * as redis from "ioredis";
import * as uuid from "uuid/v1";
import * as appConfig from "../utils/environment";
import * as errorHandler from "../utils/error.handler";
import { IImage } from "./image.schema";

const conf = appConfig.getConfig(process.env);
const redisClient = new redis(conf.redisPort, conf.redisHost);
redisClient.on("connect", function () {
  console.log("connected");
});

/**
 * Busca una imagen
 */
export interface IReadRequest extends express.Request {
  image: IImage;
}
export function read(req: IReadRequest, res: express.Response) {
  res.json(req.image);
}

/**
 * @api {post} /image Guardar Imagen
 * @apiName Guardar Imagen
 * @apiGroup Imagen
开发者ID:maticorv,项目名称:mascotas2018_foro,代码行数:31,代码来源:image.service.ts


示例4: Redis

new Redis({
    port: 6379,          // Redis port
    host: '127.0.0.1',   // Redis host
    family: 4,           // 4 (IPv4) or 6 (IPv6)
    password: 'auth',
    db: 0,
    retryStrategy: function() { return false; },
    showFriendlyErrorStack: true
})

var pub = new Redis();
redis.subscribe('news', 'music', function(err: any, count: any) {
    // Now we are subscribed to both the 'news' and 'music' channels.
    // `count` represents the number of channels we are currently subscribed to.

    pub.publish('news', 'Hello world!');
    pub.publish('music', 'Hello again!');
});

redis.on('message', function(channel: any, message: any) {
    // Receive message Hello world! from channel news
    // Receive message Hello again! from channel music
    console.log('Receive message %s from channel %s', message, channel);
});

// There's also an event called 'messageBuffer', which is the same as 'message' except
// it returns buffers instead of strings.
redis.on('messageBuffer', function(channel: any, message: any) {
    // Both `channel` and `message` are buffers.
});
开发者ID:Root-Core,项目名称:DefinitelyTyped,代码行数:30,代码来源:ioredis-tests.ts


示例5: Redis

 return T.makeTask_(cb => {
   const redis = new Redis(uri);
   redis.on('ready', () => {
     cb(null, redis);
   });
 });
开发者ID:syaiful6,项目名称:jonggrang,代码行数:6,代码来源:redis-storage.ts



注:本文中的ioredis.on函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ioredis.set函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ioredis.get函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap