当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ioredis.on函数代码示例

本文整理汇总了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;未经允许,请勿转载。