Fortran · 813 bytes Raw Blame History
1 program cache_roundtrip_demo
2 use fgof_cache, only : FGOF_CACHE_OK, clear_cache_options, read_cache_text, write_cache_text
3 use fgof_cache_types, only : cache_entry, cache_options, cache_text_result
4 implicit none
5
6 type(cache_options) :: options
7 type(cache_entry) :: entry
8 type(cache_text_result) :: read_result
9
10 options = clear_cache_options()
11 options%root_dir = "/tmp/fgof-cache-example-roundtrip"
12 options%namespace = "demo"
13
14 entry = write_cache_text("alpha", "ready", options)
15 if (entry%error_code /= FGOF_CACHE_OK) error stop "cache_roundtrip_demo: write should succeed"
16
17 read_result = read_cache_text("alpha", options)
18 if (read_result%error_code /= FGOF_CACHE_OK) error stop "cache_roundtrip_demo: read should succeed"
19
20 print "(a)", read_result%text
21 end program cache_roundtrip_demo
22