File: StatementCache.hs

package info (click to toggle)
haskell-persistent 2.14.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,120 kB
  • sloc: haskell: 12,767; makefile: 3
file content (23 lines) | stat: -rw-r--r-- 837 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Database.Persist.SqlBackend.Internal.StatementCache where

import Data.Text (Text)
import Database.Persist.SqlBackend.Internal.Statement

-- | A statement cache used to lookup statements that have already been prepared
-- for a given query.
--
-- @since 2.13.3
data StatementCache = StatementCache
    { statementCacheLookup :: StatementCacheKey -> IO (Maybe Statement)
    , statementCacheInsert :: StatementCacheKey -> Statement -> IO ()
    , statementCacheClear :: IO ()
    , statementCacheSize :: IO Int
    }

newtype StatementCacheKey = StatementCacheKey { cacheKey :: Text }
-- Wrapping around this to allow for more efficient keying mechanisms
-- in the future, perhaps.

-- | Construct a `StatementCacheKey` from a raw SQL query.
mkCacheKeyFromQuery :: Text -> StatementCacheKey
mkCacheKeyFromQuery = StatementCacheKey