diff options
Diffstat (limited to 'src/Network/BitTorrent/Internal/Cache.hs')
-rw-r--r-- | src/Network/BitTorrent/Internal/Cache.hs | 25 |
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 | ||
34 | import Control.Applicative | 34 | import Control.Applicative |
35 | import Data.Aeson | ||
36 | import Data.Monoid | 35 | import Data.Monoid |
37 | import Data.Default | 36 | import Data.Default |
38 | import Data.Time | 37 | import 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 | -- | ||
69 | instance 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 | |||
83 | instance Default (Cached a) where | 58 | instance Default (Cached a) where |
84 | def = mempty | 59 | def = mempty |
85 | 60 | ||