GithubHelp home page GithubHelp logo

redpool's Introduction

redpool

Simple Redis connection pool.

The timeout argument allows connections to be reused after a given time, in case they don't get released properly. The maxConn argument sets a soft limit, which destroys connection objects when released if the limit has been reached. The withAcquire template can be used to automatically acquire and release a connection, but note that with Nim versions below 1.3.1, the acquire call is waitFor'd since async wasn't allowed inside templates and macros before that.

Usage

import asyncdispatch, redis, redpool

proc main {.async.} =
  let pool = await newRedisPool(5, timeout=4, maxConns=7)

  # manual acquire
  let conn = await pool.acquire()
  echo await conn.ping()
  await pool.release(conn)

  # acquire template
  pool.withAcquire(conn2):
    echo await conn2.ping()

redpool's People

Contributors

heavenvolkoff avatar zedeus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

redpool's Issues

Add support for Unix sockets

Currently it seems that newRedisPool cannot connect to a Redis server using an Unix socket.

This is problematic for machines with multiple Redis instances (e.g. one Redis instance per application) that only exposes Unix sockets. It forces the user to manually choose a localhost port to bind.

Unix sockets support would also bring user/group permissions.

This would be useful to make NixOS Nitter service more secure.

Best regards,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.