Beispiel #1
0
int redisAsyncCommandArgv(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, int argc, const char **argv, const size_t *argvlen) {
    char *cmd;
    int len;
    int status;
    len = redisFormatCommandArgv(&cmd,argc,argv,argvlen);
    status = __redisAsyncCommand(ac,fn,privdata,cmd,len);
    free(cmd);
    return status;
}
Beispiel #2
0
int redisvAsyncCommand(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, const char *format, va_list ap) {
    char *cmd;
    int len;
    int status;
    len = redisvFormatCommand(&cmd,format,ap);
    status = __redisAsyncCommand(ac,fn,privdata,cmd,len);
    free(cmd);
    return status;
}
Beispiel #3
0
int redisvAsyncCommand(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, const char *format, va_list ap) {
    char *cmd;
    int len;
    int status;
    len = redisvFormatCommand(&cmd,format,ap);

    /* We don't want to pass -1 or -2 to future functions as a length. */
    if (len < 0)
        return REDIS_ERR;

    status = __redisAsyncCommand(ac,fn,privdata,cmd,len);
    free(cmd);
    return status;
}
Beispiel #4
0
/*
 * EV send callback
 *
 * EV_ASYNC send_async
 */
  static void
_eredis_ev_send_cb (struct ev_loop *loop, ev_async *w, int revents)
{
  int i, nb, l;
  char *s;
  eredis_t *e;

  (void) revents;
  (void) loop;

  e = (eredis_t*) w->data;

  e->send_async_pending = 0;

  while ((s = _eredis_wqueue_shift( e, &l ))) {
    for (nb = 0, i=0; i<e->hosts_nb; i++) {
      host_t *h = &e->hosts[i];

      if (H_IS_CONNECTED(h)) {
        __redisAsyncCommand( h->async_ctx, NULL, NULL, s, l );
        nb ++;
      }
    }

    if (
      (! nb)  /* failed to deliver to any host */
      &&
      (e->wqueue.nb < QUEUE_MAX_UNSHIFT))
    {
      /* Unshift and stop */
      _eredis_wqueue_unshift( e, s, l );
      break;
    }

    free( s );
  }
}
Beispiel #5
0
int redisAsyncFormattedCommand(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, const char *cmd, size_t len) {
    int status = __redisAsyncCommand(ac,fn,privdata,cmd,len);
    return status;
}