[OpenSIPS-Users] cache usage issue

Pyle, Jeff JPyle at fusionconnect.com
Thu Oct 17 16:44:07 UTC 2024


Hello,

I'm attempting this on 2.4 and 3.4. Here's what I have:

    loadmodule "cachedb_local.so"
    modparam("cachedb_local", "cachedb_url", "local://")

and then:

    if (condition) {
            $var(logkey) = "condition_" + $avp(user);
            if (!cache_fetch("local", "$var(logkey)", $var(devnull))) {
                    xlog("L_INFO", "log a message about a thing - fU $fU, ru $rU\n");
                    cache_store("local", "$var(logkey)", "1", 5);
            }
    }

The whole idea is to have a cache entry with a TTL of 5 seconds, so that when (condition) is true, I'll only write the xlog at most every 5 seconds to avoid flooding the log. It's not working. Instead, I write the xlog every time (condition) is true, so cache_fetch() is failing every time even though I'm running the cache_store() two lines later.

The value of the cache entry itself is irrelevant (I'm storing "1"), and returning that value doesn't matter either (I'm using $var(devnull)). The important thing is the presence or absence of the cache entry to determine whether or not we've done the xlog in the last 5 seconds.

I'm hoping someone in the community can look at this and tell me what stupid mistake I've made.


Regards,
Jeff

This message is subject to Fusion Connect, Inc.'s email communication policy: www.fusionconnect.com/email-policy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20241017/ad8017d1/attachment.html>


More information about the Users mailing list