]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_sorcery_memory_cache: Add support for maximum_objects. 27/827/1
authorMark Michelson <mmichelson@digium.com>
Wed, 20 May 2015 20:19:27 +0000 (15:19 -0500)
committerMark Michelson <mmichelson@digium.com>
Wed, 8 Jul 2015 19:34:43 +0000 (14:34 -0500)
commit9ae9221d2b53f13bf06235ce46b55d6d485c624a
treefccbfc01a69d0aa24952cb594c11f5362d75d2e7
parente4d42119b5d772ab905fe5998c805772c37c0bde
res_sorcery_memory_cache: Add support for maximum_objects.

This makes the "maximum_objects" option operational.

A heap has been added alongside the hash table in the cache. When
objects are added to the cache, they are also added to the heap.
Similarly, when objects are removed from the cache, they are removed
from the heap.

The heap's use comes into play when an item is to be added to a "full"
cache. When the cache is full, the oldest item is removed from the
cache, using the heap to determine the oldest item.

A unit test has been added that verifies that the maximum_objects option
works as expected and that the oldest object is removed from the cache
when an object beyond the maximum is added.

ASTERISK-25067 #close
Reported by Matt Jordan

Change-Id: I490658830e9c4cbf0b3051e4cdc4913cf9f1b73a
res/res_sorcery_memory_cache.c