This module provides a thin FFI binding to the libtokyotyrant C library shipped with Mikio Hirabayashi's Tokyo Tyrant. (http://tokyocabinet.sourceforge.net/tyrantdoc/)
It's intended to be imported qualified, e.g.:
import qualified Database.TokyoTyrant.FFI as TT
- open :: ByteString -> Int -> IO (Either String Connection)
- close :: Connection -> IO ()
- get :: Connection -> ByteString -> IO (Either String (Maybe ByteString))
- put :: Connection -> ByteString -> ByteString -> IO (Either String ())
- putKeep :: Connection -> ByteString -> ByteString -> IO (Either String ())
- mget :: Connection -> [ByteString] -> IO (Either String [(ByteString, ByteString)])
- mput :: Connection -> [(ByteString, ByteString)] -> IO (Either String ())
- delete :: Connection -> ByteString -> IO (Either String ())
- vanish :: Connection -> IO (Either String ())
- fwmkeys :: Connection -> ByteString -> Int -> IO (Either String [ByteString])
- data Connection
Opening/closing connections
:: ByteString | hostname |
-> Int | port |
-> IO (Either String Connection) |
Open a connection to Tokyo Tyrant.
close :: Connection -> IO ()Source
Close a connection to Tokyo Tyrant
Fetching/storing single values from the store
:: Connection | connection |
-> ByteString | key |
-> IO (Either String (Maybe ByteString)) |
Get a value from the database
:: Connection | connection |
-> ByteString | key |
-> ByteString | value |
-> IO (Either String ()) |
Store a value in the database (destructive, overwrites any existing value)
:: Connection | connection |
-> ByteString | key |
-> ByteString | value |
-> IO (Either String ()) |
Store a value in the database (non-destructive, does nothing if the key already exists)
Fetching/storing multiple values from the store
:: Connection | connection to DB |
-> [ByteString] | list of keys to fetch |
-> IO (Either String [(ByteString, ByteString)]) |
Get multiple values from the database. On success, returns `Right kvps`.
:: Connection | connection to DB |
-> [(ByteString, ByteString)] | list of key-value pairs |
-> IO (Either String ()) |
Put multiple values to the database.
Deleting keys
:: Connection | connection |
-> ByteString | key |
-> IO (Either String ()) |
Delete a value from the DB
Key prefix search
:: Connection | connection to DB |
-> ByteString | key prefix |
-> Int | max # of returned keys; negative numbers mean no limit |
-> IO (Either String [ByteString]) |
Search keys by prefix. Returns a list of matching keys.
Types
data Connection Source
A Tokyo Tyrant connection type. Wraps the TCRDB
type from the C
library.