| 1 |
program cache_prune_demo |
| 2 |
use iso_fortran_env, only : int64 |
| 3 |
use fgof_cache, only : & |
| 4 |
FGOF_CACHE_OK, & |
| 5 |
clear_cache_options, & |
| 6 |
prune_stale_cache, & |
| 7 |
write_cache_text |
| 8 |
use fgof_cache_types, only : cache_entry, cache_options, cache_prune_result |
| 9 |
implicit none |
| 10 |
|
| 11 |
type(cache_options) :: options |
| 12 |
type(cache_entry) :: entry |
| 13 |
type(cache_prune_result) :: prune_result |
| 14 |
|
| 15 |
options = clear_cache_options() |
| 16 |
options%root_dir = "/tmp/fgof-cache-example-prune" |
| 17 |
options%namespace = "demo" |
| 18 |
|
| 19 |
entry = write_cache_text("alpha", "one", options) |
| 20 |
if (entry%error_code /= FGOF_CACHE_OK) error stop "cache_prune_demo: first write should succeed" |
| 21 |
|
| 22 |
entry = write_cache_text("beta", "two", options) |
| 23 |
if (entry%error_code /= FGOF_CACHE_OK) error stop "cache_prune_demo: second write should succeed" |
| 24 |
|
| 25 |
prune_result = prune_stale_cache(60_int64, options, entry%modified_time_seconds + 120_int64) |
| 26 |
if (prune_result%error_code /= FGOF_CACHE_OK) error stop "cache_prune_demo: prune should succeed" |
| 27 |
|
| 28 |
print "(a,i0)", "removed=", prune_result%removed_count |
| 29 |
end program cache_prune_demo |
| 30 |
|