Convert to use hashtables, as Data.HashTable went away.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
Edward Z. Yang 2013-11-06 23:04:16 -08:00
parent 6b37a429d4
commit 5656f90c27
2 changed files with 4 additions and 3 deletions

View file

@ -35,7 +35,7 @@ import Data.IORef (IORef, newIORef, readIORef, writeIORef)
import Data.Set (Set)
import System.IO.Unsafe (unsafePerformIO)
import qualified Data.HashTable as H
import qualified Data.HashTable.IO as H
import qualified Data.Set as Set
import Control.Monad.Trans (MonadIO, liftIO)
@ -148,7 +148,7 @@ dropIndexes coll = do
-- *** Index cache
type DbIndexCache = H.HashTable Database IndexCache
type DbIndexCache = H.BasicHashTable Database IndexCache
-- ^ Cache the indexes we create so repeatedly calling ensureIndex only hits database the first time. Clear cache every once in a while so if someone else deletes index we will recreate it on ensureIndex.
type IndexCache = IORef (Set (Collection, IndexName))
@ -156,7 +156,7 @@ type IndexCache = IORef (Set (Collection, IndexName))
dbIndexCache :: DbIndexCache
-- ^ initialize cache and fork thread that clears it every 15 minutes
dbIndexCache = unsafePerformIO $ do
table <- H.new (==) (H.hashString . T.unpack)
table <- H.new
_ <- forkIO . forever $ threadDelay 900000000 >> clearDbIndexCache
return table
{-# NOINLINE dbIndexCache #-}

View file

@ -37,6 +37,7 @@ Library
, monad-control >= 0.3.1
, lifted-base >= 0.1.0.3
, transformers-base >= 0.4.1
, hashtables >= 1.1.2.0
Exposed-modules: Database.MongoDB
Database.MongoDB.Admin