當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。