redis 0.1 → 0.2
raw patch · 6 files changed
+125/−10 lines, 6 files
Files
- Database/Redis/Monad.hs +26/−1
- Database/Redis/Monad/State.hs +22/−0
- Database/Redis/Redis.hs +32/−4
- Database/Redis/Utils/Lock.hs +22/−0
- Database/Redis/Utils/Monad/Lock.hs +22/−4
- redis.cabal +1/−1
Database/Redis/Monad.hs view
@@ -1,3 +1,25 @@+{-+Copyright (c) 2010 Alexander Bogdanov <andorn@gmail.com>++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+-}+ {-# LANGUAGE FlexibleContexts #-} -- | Monadic wrapper for "Database.Redis.Redis"@@ -21,7 +43,7 @@ -- * Redis commands -- ** Generic ping, auth, quit, shutdown,- multi, exec, run_multi, exists,+ multi, exec, discard, run_multi, exists, del, getType, keys, randomKey, rename, renameNx, dbsize, expire, expireAt, ttl, select, move, flushDb,@@ -94,6 +116,9 @@ exec :: WithRedis m => m R.Reply exec = getRedis >>= liftIO . R.exec++discard :: WithRedis m => m R.Reply+discard = getRedis >>= liftIO . R.discard run_multi :: WithRedis m => [m R.Reply] -> m R.Reply run_multi cs = let cs' = map (>>= R.noError) cs
Database/Redis/Monad/State.hs view
@@ -1,3 +1,25 @@+{-+Copyright (c) 2010 Alexander Bogdanov <andorn@gmail.com>++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+-}+ {-# LANGUAGE TypeSynonymInstances #-} -- | This module is mainly an example of posible 'WithRedis' -- implementation
Database/Redis/Redis.hs view
@@ -1,3 +1,25 @@+{-+Copyright (c) 2010 Alexander Bogdanov <andorn@gmail.com>++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+-}+ {-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, FunctionalDependencies, FlexibleContexts #-} -- | Main Redis API and protocol implementation@@ -19,7 +41,7 @@ -- * Redis commands -- ** Generic ping, auth, quit, shutdown,- multi, exec, run_multi, exists,+ multi, exec, discard, run_multi, exists, del, getType, keys, randomKey, rename, renameNx, dbsize, expire, expireAt, ttl, select, move, flushDb,@@ -309,6 +331,12 @@ exec :: Redis -> IO Reply exec r = sendCommand r (CInline "EXEC") >> recv r +-- | Discard queued commands without execution+--+-- ROk returned+discard :: Redis -> IO Reply+discard r = sendCommand r (CInline "DISCARD") >> recv r+ -- | Run commands within multi-exec block -- -- RMulti returned - replys for all executed commands@@ -344,11 +372,11 @@ -> IO Reply getType r key = sendCommand r (CMBulk ["TYPE", key]) >> recv r --- | Returns all the keys matching the glob-style pattern as space separated strings+-- | Returns all the keys matching the glob-style pattern ----- RBulk returned+-- RMulti filled with RBulk returned keys :: Redis- -> String -- ^ target key+ -> String -- ^ target keys pattern -> IO Reply keys r pattern = sendCommand r (CMInline ["KEYS", pattern]) >> recv r
Database/Redis/Utils/Lock.hs view
@@ -1,3 +1,25 @@+{-+Copyright (c) 2010 Alexander Bogdanov <andorn@gmail.com>++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+-}+ -- | Emulating locking primitives module Database.Redis.Utils.Lock ( acquire, acquire', acquireOnce, release ) where
Database/Redis/Utils/Monad/Lock.hs view
@@ -1,3 +1,25 @@+{-+Copyright (c) 2010 Alexander Bogdanov <andorn@gmail.com>++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+-}+ -- | Same as "Database.Redis.Utils.Lock" but with monadic wrapped module Database.Redis.Utils.Monad.Lock (acquire, acquire', acquireOnce, release) where @@ -5,10 +27,6 @@ import qualified Database.Redis.Utils.Lock as L import Database.Redis.Monad (WithRedis(..)) -{-- timeout - сколько пытаться захватить лок, ms- retry_timeout - сколько ждать между попытками, ms- -} acquire :: WithRedis m => String -> Int -> Int -> m Bool acquire name timeout retry_timeout = do r <- getRedis
redis.cabal view
@@ -1,5 +1,5 @@ Name: redis-Version: 0.1+Version: 0.2 License: MIT Maintainer: Alexander Bogdanov <andorn@gmail.com> Author: Alexander Bogdanov <andorn@gmail.com>