module Ecluse.Core.Server.Cache.Backend.Internal (
RetentionBackend (..),
RetentionOperations (..),
BackendStorage (..),
Recency (..),
CacheOccupancy (..),
) where
data RetentionBackend k v = RetentionBackend
{ forall k v. RetentionBackend k v -> BackendStorage
rbStorage :: BackendStorage
, forall k v.
RetentionBackend k v
-> (CacheOccupancy -> IO ())
-> IO ()
-> Recency
-> k
-> IO (Maybe v)
rbLookup :: (CacheOccupancy -> IO ()) -> IO () -> Recency -> k -> IO (Maybe v)
, forall k v.
RetentionBackend k v
-> (CacheOccupancy -> IO ()) -> IO () -> IO () -> k -> v -> IO ()
rbInsert :: (CacheOccupancy -> IO ()) -> IO () -> IO () -> k -> v -> IO ()
}
data RetentionOperations k v = RetentionOperations
{ forall k v.
RetentionOperations k v
-> (CacheOccupancy -> IO ()) -> Recency -> k -> IO (Maybe v)
roLookup :: (CacheOccupancy -> IO ()) -> Recency -> k -> IO (Maybe v)
, forall k v.
RetentionOperations k v
-> (CacheOccupancy -> IO ()) -> IO () -> k -> v -> IO ()
roInsert :: (CacheOccupancy -> IO ()) -> IO () -> k -> v -> IO ()
}
data BackendStorage
= LocalStorage
|
ExternalStorage Int
deriving stock (BackendStorage -> BackendStorage -> Bool
(BackendStorage -> BackendStorage -> Bool)
-> (BackendStorage -> BackendStorage -> Bool) -> Eq BackendStorage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BackendStorage -> BackendStorage -> Bool
== :: BackendStorage -> BackendStorage -> Bool
$c/= :: BackendStorage -> BackendStorage -> Bool
/= :: BackendStorage -> BackendStorage -> Bool
Eq, Int -> BackendStorage -> ShowS
[BackendStorage] -> ShowS
BackendStorage -> String
(Int -> BackendStorage -> ShowS)
-> (BackendStorage -> String)
-> ([BackendStorage] -> ShowS)
-> Show BackendStorage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BackendStorage -> ShowS
showsPrec :: Int -> BackendStorage -> ShowS
$cshow :: BackendStorage -> String
show :: BackendStorage -> String
$cshowList :: [BackendStorage] -> ShowS
showList :: [BackendStorage] -> ShowS
Show)
data Recency = PreserveRecency | RefreshRecency
deriving stock (Recency -> Recency -> Bool
(Recency -> Recency -> Bool)
-> (Recency -> Recency -> Bool) -> Eq Recency
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Recency -> Recency -> Bool
== :: Recency -> Recency -> Bool
$c/= :: Recency -> Recency -> Bool
/= :: Recency -> Recency -> Bool
Eq, Int -> Recency -> ShowS
[Recency] -> ShowS
Recency -> String
(Int -> Recency -> ShowS)
-> (Recency -> String) -> ([Recency] -> ShowS) -> Show Recency
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Recency -> ShowS
showsPrec :: Int -> Recency -> ShowS
$cshow :: Recency -> String
show :: Recency -> String
$cshowList :: [Recency] -> ShowS
showList :: [Recency] -> ShowS
Show)
data CacheOccupancy = CacheOccupancy
{ CacheOccupancy -> Int
occEntries :: Int
, CacheOccupancy -> Int
occBytes :: Int
}
deriving stock (CacheOccupancy -> CacheOccupancy -> Bool
(CacheOccupancy -> CacheOccupancy -> Bool)
-> (CacheOccupancy -> CacheOccupancy -> Bool) -> Eq CacheOccupancy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CacheOccupancy -> CacheOccupancy -> Bool
== :: CacheOccupancy -> CacheOccupancy -> Bool
$c/= :: CacheOccupancy -> CacheOccupancy -> Bool
/= :: CacheOccupancy -> CacheOccupancy -> Bool
Eq, Int -> CacheOccupancy -> ShowS
[CacheOccupancy] -> ShowS
CacheOccupancy -> String
(Int -> CacheOccupancy -> ShowS)
-> (CacheOccupancy -> String)
-> ([CacheOccupancy] -> ShowS)
-> Show CacheOccupancy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CacheOccupancy -> ShowS
showsPrec :: Int -> CacheOccupancy -> ShowS
$cshow :: CacheOccupancy -> String
show :: CacheOccupancy -> String
$cshowList :: [CacheOccupancy] -> ShowS
showList :: [CacheOccupancy] -> ShowS
Show)