2019-04-17 12:48:41 +03:00
|
|
|
module Hasura.Cache
|
2020-05-13 12:17:32 +03:00
|
|
|
( module Hasura.Cache.Types
|
|
|
|
, B.CacheSize(..)
|
|
|
|
, B.parseCacheSize
|
2019-11-25 20:12:23 +03:00
|
|
|
, initialise
|
2019-04-17 12:48:41 +03:00
|
|
|
) where
|
|
|
|
|
2019-11-25 20:12:23 +03:00
|
|
|
import Hasura.Prelude hiding (lookup)
|
2019-04-17 12:48:41 +03:00
|
|
|
|
2020-05-13 12:17:32 +03:00
|
|
|
import Hasura.Cache.Types
|
2019-11-25 20:12:23 +03:00
|
|
|
import qualified Hasura.Cache.Bounded as B
|
|
|
|
import qualified Hasura.Cache.Unbounded as U
|
2019-04-17 12:48:41 +03:00
|
|
|
|
2020-05-13 12:17:32 +03:00
|
|
|
initialise :: (Hashable k, Ord k) => Maybe B.CacheSize -> IO (Cache k v)
|
|
|
|
initialise cacheSizeM =
|
2019-11-25 20:12:23 +03:00
|
|
|
case cacheSizeM of
|
2020-05-13 12:17:32 +03:00
|
|
|
Nothing -> Cache <$> U.initialise
|
|
|
|
Just cacheSize -> Cache <$> B.initialise cacheSize
|