]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_sorcery_memory_cache: Add support for refreshing stale objects. 29/829/1
authorMark Michelson <mmichelson@digium.com>
Tue, 26 May 2015 18:01:24 +0000 (13:01 -0500)
committerMark Michelson <mmichelson@digium.com>
Wed, 8 Jul 2015 19:34:50 +0000 (14:34 -0500)
commit9c2de310be6ad11f954133a259e0a57fadc0c352
treed5d10003905041e58bc2589fcd09f19c5bc464be
parent9a7fccc50c7ce34ca5b10efb208ba68fa750ddeb
res_sorcery_memory_cache: Add support for refreshing stale objects.

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
res/res_sorcery_memory_cache.c