Concurrent DB connection pool in Haskell

后端 未结 3 1614
無奈伤痛
無奈伤痛 2021-02-06 00:15

I am a Java programmer who learns Haskell.
I work on a small web-app that uses Happstack and talks to a database via HDBC.

I\'ve written select and

3条回答
  •  心在旅途
    2021-02-06 00:59

    The resource-pool package provides a high-performance resource pool which can be used for database connection pooling. For example:

    import Data.Pool (createPool, withResource)
    
    main = do
        pool <- createPool newConn delConn 1 10 5
        withResource pool $ \conn -> doSomething conn
    

    Creates a database connection pool with 1 sub-pool and up to 5 connections. Each connection is allowed to be idle for 10 seconds before being destroyed.

提交回复
热议问题