[OpenSIPS-Users] OpenSIPS 3.1 - Test if cache is empty?
Mark Allen
mark at allenclan.co.uk
Wed Dec 2 16:16:26 EST 2020
Thanks so much for your help Liviu. In the end, I used the $shv() approach
you suggested. It worked like a dream! :-)
In opensips.cfg:
loadmodule "cfgutils.so"
modparam("cfgutils", "shvset", "cacheValid=i:0")
route{
if ($shv(cacheValid) == 0) {
xlog("Reloading cache");
...code to reload cached data goes here...
$shv(cacheValid) = 1;
}
Trigger reload using opensips-cli:
opensips-cli -x mi shv_set cacheValid int 0
On Wed, 25 Nov 2020 at 14:26, Liviu Chircu <liviu at opensips.org> wrote:
> On 25.11.2020 16:18, Mark Allen wrote:
> > If the DB table is updated I can flush the cache of the old data with
> > "opensips-cli -x mi cache_remove_chunk". I would then want to have a
> > test in OpenSIPS that says that if the cache is empty, re-populate it
> > from the DB. Is this possible?
>
> Hi, Mark!
>
> From my knowledge, the "cachedb is empty" test is not available right now.
>
> However, why not use either the recently added "raise_event" [1]
> function, or even a shared $shv(cache_reset) variable [2] as a pure
> "on/off" binary marker in order to hook into the opensips.cfg
> environment via MI interface and then instruct OpenSIPS to do a
> cache_remove_chunk() [3], followed by re-populating the cache?
>
> [1]: https://www.opensips.org/Documentation/Interface-CoreMI-3-2#toc20
> [2]: https://opensips.org/docs/modules/3.2.x/cfgutils.html#idp337920
> [3]:
>
> https://opensips.org/docs/modules/3.2.x/cachedb_local.html#func_cache_remove_chunk
>
> Best regards,
>
> --
> Liviu Chircu
> www.twitter.com/liviuchircu | www.opensips-solutions.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20201202/f8a5923c/attachment.html>
More information about the Users
mailing list