module_cache_t Derived Type

type, public :: module_cache_t

Type for managing module-level caching


Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: cache_dir

Base cache directory

character(len=:), public, allocatable :: compiler_id

Compiler identifier for cache segregation

character(len=:), public, allocatable :: compiler_version

Compiler version for cache segregation

logical, public :: enabled = .true.

Whether caching is enabled


Type-Bound Procedures

procedure, public :: init => cache_init

  • private subroutine cache_init(this, compiler, compiler_version)

    Initialize the module cache

    Arguments

    Type IntentOptional Attributes Name
    class(module_cache_t), intent(inout) :: this
    type(compiler_t), intent(in) :: compiler
    character(len=*), intent(in), optional :: compiler_version

procedure, public :: get_cache_key => cache_get_key

  • private function cache_get_key(this, srcfile, dependencies) result(key)

    Generate cache key for a source file

    Arguments

    Type IntentOptional Attributes Name
    class(module_cache_t), intent(in) :: this
    type(srcfile_t), intent(in) :: srcfile
    type(srcfile_t), intent(in), optional :: dependencies(:)

    Return Value character(len=64)

procedure, public :: store_module => cache_store_module

  • private subroutine cache_store_module(this, srcfile, cache_key, build_dir, error)

    Store a compiled module in the cache

    Arguments

    Type IntentOptional Attributes Name
    class(module_cache_t), intent(in) :: this
    type(srcfile_t), intent(in) :: srcfile
    character(len=*), intent(in) :: cache_key
    character(len=*), intent(in) :: build_dir
    type(error_t), intent(out), allocatable :: error

procedure, public :: retrieve_module => cache_retrieve_module

  • private subroutine cache_retrieve_module(this, cache_key, target_dir, srcfile, found, error)

    Retrieve a cached module

    Arguments

    Type IntentOptional Attributes Name
    class(module_cache_t), intent(in) :: this
    character(len=*), intent(in) :: cache_key
    character(len=*), intent(in) :: target_dir
    type(srcfile_t), intent(in) :: srcfile
    logical, intent(out) :: found
    type(error_t), intent(out), allocatable :: error

procedure, public :: is_cached => cache_is_cached

  • private function cache_is_cached(this, cache_key) result(is_cached)

    Check if a module is cached

    Arguments

    Type IntentOptional Attributes Name
    class(module_cache_t), intent(in) :: this
    character(len=*), intent(in) :: cache_key

    Return Value logical

procedure, public :: get_module_dir => cache_get_module_dir

  • private function cache_get_module_dir(this, cache_key) result(dir)

    Get the cache directory for a specific module

    Arguments

    Type IntentOptional Attributes Name
    class(module_cache_t), intent(in) :: this
    character(len=*), intent(in) :: cache_key

    Return Value character(len=:), allocatable

procedure, public :: clean_stale => cache_clean_stale

  • private subroutine cache_clean_stale(this, max_age_days, error)

    Clean stale cache entries

    Arguments

    Type IntentOptional Attributes Name
    class(module_cache_t), intent(in) :: this
    integer, intent(in) :: max_age_days
    type(error_t), intent(out), allocatable :: error

procedure, public :: deep_copy => cache_deep_copy

  • private function cache_deep_copy(this) result(copy)

    Deep copy procedures for module_cache_t

    Arguments

    Type IntentOptional Attributes Name
    class(module_cache_t), intent(in) :: this

    Return Value type(module_cache_t)

procedure, public :: assign => cache_assign

  • private subroutine cache_assign(lhs, rhs)

    Arguments

    Type IntentOptional Attributes Name
    class(module_cache_t), intent(out) :: lhs
    type(module_cache_t), intent(in) :: rhs

generic, public :: assignment(=) => assign

  • private subroutine cache_assign(lhs, rhs)

    Arguments

    Type IntentOptional Attributes Name
    class(module_cache_t), intent(out) :: lhs
    type(module_cache_t), intent(in) :: rhs

Source Code

    type :: module_cache_t
        !> Base cache directory
        character(:), allocatable :: cache_dir

        !> Compiler identifier for cache segregation
        character(:), allocatable :: compiler_id

        !> Compiler version for cache segregation
        character(:), allocatable :: compiler_version

        !> Whether caching is enabled
        logical :: enabled = .true.

    contains
        procedure :: init => cache_init
        procedure :: get_cache_key => cache_get_key
        procedure :: store_module => cache_store_module
        procedure :: retrieve_module => cache_retrieve_module
        procedure :: is_cached => cache_is_cached
        procedure :: get_module_dir => cache_get_module_dir
        procedure :: clean_stale => cache_clean_stale
        procedure :: deep_copy => cache_deep_copy
        procedure :: assign => cache_assign
        generic :: assignment(=) => assign
    end type module_cache_t