homepage: https://github.com/juhp/cached-json-file
changelog-type: markdown
hash: dd5822f5fd007b094d0c275d92c6900adde60ee4f2e2b32dc16c08c8ca0eff16
test-bench-deps: {}
maintainer: Jens Petersen <juhpetersen@gmail.com>
synopsis: Locally cache a json file obtained by http
changelog: |
  # Version history for cached-json-file

  ## 0.1.0 (2021-07-29)
  - initial release with getCachedJSON and getCachedJSONQuery
  - exports lookupKey from http-query
basic-deps:
  xdg-basedir: -any
  bytestring: -any
  base: <5
  time: -any
  filepath: -any
  http-query: -any
  aeson: -any
  directory: -any
all-versions:
- 0.1.0
author: Jens Petersen <juhpetersen@gmail.com>
latest: 0.1.0
description-type: markdown
description: |
  # cached-json-file

  A Haskell library providing a cached json file.

  Useful for frequently used programs that use some remote json data
  which changes rather slowly (like in hours, days, weeks or months),
  where it is not critical to have always the latest data immediately.

  ## Usage

  `getCachedJSON dir file url minutes` caches the json obtained from `url` in
  `~/.cache/dir/file` for `minutes`.

  eg:

  ```haskell
  import System.Cached.JSON

  getSnapshots :: IO Object
  getSnapshots =
    getCachedJSON "stackage-snapshots" "snapshots.json" "http://haddock.stackage.org/snapshots.json" 180

  main = getSnapshots >>= print
  ```

  Each time you run this program within 3 hours the data will be read
  from the local cache file `~/.cache/stackage-snapshots/snapshots.json`
  rather than re-downloading it each time,
  which helps to speed up the program and avoid unnecessary web queries.

  There is also `getCachedJSONQuery prog jsonfile webquery minutes`
  which uses `webquery :: (FromJSON a, ToJSON a) => IO a` to download
  the json data.

  Currently the smallest possible cache time is 1 minute.
license-name: BSD-3-Clause

Update from Hackage at 2021-07-29T06:38:46Z
Update from Hackage at 2021-07-29T06:38:46Z
