Skip to content
Snippets Groups Projects
  • Mark Michelson's avatar
    2e54e722
    res_sorcery_memory_cache: Add support for refreshing stale objects. · 2e54e722
    Mark Michelson authored
    This change introduces a check of object_lifetime_stale when retrieving
    cached objects. If the amount of time the object has been in the cache
    exceeds the lifetime, then a task is scheduled to update the cached
    object based on an object retrieved from other sorcery wizards instead.
    
    To prevent the cached object from being retrieved during a refresh,
    thread-local storage is used to mark the thread as being a stale object
    update. This results in the cache returning no object, leading to
    sorcery querying other wizards for the object instead.
    
    A test has been added for stale objects as well. This test ensures that
    stale objects are retrieved the same as freshly-cached objects. The test
    also ensures that after an object is stale, changes in the backend are
    reflected in the cache, to include if the object has been deleted from
    the backend.
    
    ASTERISK-25067
    Reported by Matt Jordan
    
    Change-Id: I9bd7c049adf6939bfe2899f393c2bfbbf412d217
    2e54e722
    History
    res_sorcery_memory_cache: Add support for refreshing stale objects.
    Mark Michelson authored
    This change introduces a check of object_lifetime_stale when retrieving
    cached objects. If the amount of time the object has been in the cache
    exceeds the lifetime, then a task is scheduled to update the cached
    object based on an object retrieved from other sorcery wizards instead.
    
    To prevent the cached object from being retrieved during a refresh,
    thread-local storage is used to mark the thread as being a stale object
    update. This results in the cache returning no object, leading to
    sorcery querying other wizards for the object instead.
    
    A test has been added for stale objects as well. This test ensures that
    stale objects are retrieved the same as freshly-cached objects. The test
    also ensures that after an object is stale, changes in the backend are
    reflected in the cache, to include if the object has been deleted from
    the backend.
    
    ASTERISK-25067
    Reported by Matt Jordan
    
    Change-Id: I9bd7c049adf6939bfe2899f393c2bfbbf412d217