summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Internal/Cache.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Internal/Cache.hs')
-rw-r--r--src/Network/BitTorrent/Internal/Cache.hs25
1 files changed, 0 insertions, 25 deletions
diff --git a/src/Network/BitTorrent/Internal/Cache.hs b/src/Network/BitTorrent/Internal/Cache.hs
index 5c3f379b..8c74467a 100644
--- a/src/Network/BitTorrent/Internal/Cache.hs
+++ b/src/Network/BitTorrent/Internal/Cache.hs
@@ -32,7 +32,6 @@ module Network.BitTorrent.Internal.Cache
32 ) where 32 ) where
33 33
34import Control.Applicative 34import Control.Applicative
35import Data.Aeson
36import Data.Monoid 35import Data.Monoid
37import Data.Default 36import Data.Default
38import Data.Time 37import Data.Time
@@ -56,30 +55,6 @@ data Cached a = Cached
56 55
57-- INVARIANT: minUpdateInterval <= updateInterval 56-- INVARIANT: minUpdateInterval <= updateInterval
58 57
59-- | Examples:
60--
61-- { data: "some string",
62-- observed: "2014-03-20T19:49:39.505Z",
63-- expires: "2014-03-20T19:50:10.881Z" }
64--
65-- or:
66--
67-- { expired: "2014-03-20T19:50:10.881Z" }
68--
69instance ToJSON a => ToJSON (Cached a) where
70 toJSON Cached {..}
71 | currentTime < expireTime = object
72 [ "observed" .= posixSecondsToUTCTime lastUpdated
73 , "expires" .= posixSecondsToUTCTime expireTime
74 , "data" .= cachedData
75 ]
76 | otherwise = object
77 [ "expired" .= posixSecondsToUTCTime expireTime
78 ]
79 where
80 expireTime = currentTime + updateInterval
81 currentTime = unsafePerformIO getPOSIXTime
82
83instance Default (Cached a) where 58instance Default (Cached a) where
84 def = mempty 59 def = mempty
85 60