Database.Persist.SqlBackend.StatementCache

persistent-2.14.6.3: Type-safe, multi-backend data serialization.

Safe Haskell | None
Language | Haskell2010

Database.Persist.SqlBackend.StatementCache

Synopsis

- data StatementCache
- data StatementCacheKey
- mkCacheKeyFromQuery :: Text -> StatementCacheKey
- data MkStatementCache = MkStatementCache {
  - statementCacheLookup :: StatementCacheKey -> IO (Maybe Statement)
  - statementCacheInsert :: StatementCacheKey -> Statement -> IO ()
  - statementCacheClear :: IO ()
  - statementCacheSize :: IO Int
  }
- mkSimpleStatementCache :: IORef (Map Text Statement) -> MkStatementCache
- mkStatementCache :: MkStatementCache -> StatementCache

# Documentation

data StatementCache #

A statement cache used to lookup statements that have already been prepared for a given query.

Since: 2.13.3

data StatementCacheKey #

mkCacheKeyFromQuery :: Text -> StatementCacheKey #

Construct a `StatementCacheKey` from a raw SQL query.

data MkStatementCache #

Configuration parameters for creating a custom statement cache

Since: 2.13.3

Constructors

MkStatementCache |
Fields statementCacheLookup :: StatementCacheKey -> IO (Maybe Statement) Retrieve a statement from the cache, or return nothing if it is not found. Since: 2.13.3 statementCacheInsert :: StatementCacheKey -> Statement -> IO () Put a new statement into the cache. An immediate lookup of the statement MUST return the inserted statement for the given cache key. Depending on the implementation, the statement cache MAY choose to evict other statements from the cache within this function. Since: 2.13.3 statementCacheClear :: IO () Remove all statements from the cache. Implementations of this should be sure to call `stmtFinalize` on all statements removed from the cache. Since: 2.13.3 statementCacheSize :: IO Int Get the current size of the cache. Since: 2.13.3

mkSimpleStatementCache :: IORef (Map Text Statement) -> MkStatementCache #

Make a simple statement cache that will cache statements if they are not currently cached.

Since: 2.13.3

mkStatementCache :: MkStatementCache -> StatementCache #

Create a statement cache.

Since: 2.13.0