keyed-vals-0.2.3.1: An abstract Handle for accessing collections in stores like Redis
Copyright(c) 2018-2022 Tim Emiola
LicenseBSD3
MaintainerTim Emiola <tim@emio.la>
Safe HaskellSafe-Inferred
LanguageHaskell2010

KeyedVals.Handle

Description

Declares the abstract Handle and combinators used to load and save keyed values.

Synopsis

Handle and related types and functions

data Handle m Source #

A handle for accessing the ValsByKey store.

data HandleErr Source #

Represents the errors that might arise in Handle functions

countKVs :: Handle m -> Key -> m (Either HandleErr Natural) Source #

Determines the number of Vals in a ValsByKey.

loadVal :: Handle m -> Key -> m (Either HandleErr (Maybe Val)) Source #

Loads the saved Val corresponding to a Key.

saveVal :: Handle m -> Key -> Val -> m (Either HandleErr ()) Source #

Saves a Val for Key.

saveKVs :: Handle m -> Key -> ValsByKey -> m (Either HandleErr ()) Source #

Saves a ValsByKey .

updateKVs :: Handle m -> Key -> ValsByKey -> m (Either HandleErr ()) Source #

Updates the stored ValsByKey from the given ValsByKey.

loadSlice :: Handle m -> Key -> Selection -> m (Either HandleErr ValsByKey) Source #

Loads a ValsByKey that only includes Vals whose keys match a Selection.

loadFrom :: Handle m -> Key -> Key -> m (Either HandleErr (Maybe Val)) Source #

Loads a Val from a ValsByKey.

saveTo :: Handle m -> Key -> Key -> Val -> m (Either HandleErr ()) Source #

Saves a Val in a ValsByKey.

deleteKeys :: Handle m -> NonEmpty Key -> m (Either HandleErr ()) Source #

Deletes Vals stored with the given Keys.

deleteKeysFrom :: Handle m -> Key -> NonEmpty Key -> m (Either HandleErr ()) Source #

Deletes Vals for the given Keys from a ValsByKey.

deleteMatches :: Handle m -> Glob -> m (Either HandleErr ()) Source #

Deletes Vals whose Keys match a Glob.

deleteMatchesFrom :: Handle m -> Key -> Glob -> m (Either HandleErr ()) Source #

Deletes Vals whose Keys match a Glob from a ValsByKey

deleteSelected :: Handle m -> Selection -> m (Either HandleErr ()) Source #

Deletes Vals that match a Selection.

deleteSelectedFrom :: Handle m -> Key -> Selection -> m (Either HandleErr ()) Source #

Deletes Vals whose Keys match a Selection from a ValsByKey

Selection and Glob

data Selection Source #

Represents ways of restricting the keys used in a ValsByKey

Constructors

Match !Glob

any keys that match the glob pattern

AllOf !(NonEmpty Key)

any of the specified keys

Instances

Instances details
Show Selection Source # 
Instance details

Defined in KeyedVals.Handle.Internal

Eq Selection Source # 
Instance details

Defined in KeyedVals.Handle.Internal

data Glob Source #

Represents a redis glob use to select keys

Instances

Instances details
Show Glob Source # 
Instance details

Defined in KeyedVals.Handle.Internal

Methods

showsPrec :: Int -> Glob -> ShowS #

show :: Glob -> String #

showList :: [Glob] -> ShowS #

Eq Glob Source # 
Instance details

Defined in KeyedVals.Handle.Internal

Methods

(==) :: Glob -> Glob -> Bool #

(/=) :: Glob -> Glob -> Bool #

mkGlob :: ByteString -> Maybe Glob Source #

constructor for a Glob

returns Nothing if the pattern is invalid

isIn :: ByteString -> Selection -> Bool Source #

tests if a ByteString matches a Selection

aliases used by the Handle functions

type Key = ByteString Source #

Represents a key used to store a Val.

type Val = ByteString Source #

Represents a value stored in the service.

type ValsByKey = Map Key Val Source #

Represents a related group of Vals stored by Key.