[OpenSIPS-Users] variable/avp value check

Alexey slackway2me at gmail.com
Mon Feb 12 09:22:15 UTC 2024


Hi list,

We implemented next config:

# cachedb module
loadmodule "cachedb_local.so"
modparam("cachedb_local", "cachedb_url", "local:///my_cache")
modparam("cachedb_local", "cache_collections", "my_cache")

# sql_cacher module
loadmodule "sql_cacher.so"
modparam("sql_cacher", "cache_table", "id=my_cache
db_url=mysql://opensips:opensipsrw@x.x.x.x/opensips
cachedb_url=local:///my_cache
table=test
key=base_id
on_demand=0
")


$avp(list) = $sql_cached_value(my_cache:base_id:key1);
    xlog(" local_cash id = $(avp(list)[*])\n");
avp_print();



The DB is something like that:
+----+------------+-----------+---+
| id | base_id | comment    |
+----+------------+-----------+---+
|  1 |     111     | id_111        |
|  2 |     222     | id_222       |
|  3 |     333     | id_333       |
|  4 |     ...        | id_...          |
+----+------------+-----------+---+


It seems the  $sql_cached_value can extract the only one row
which is mentioned in the ‘key’ value from the cached DB.
But our goal is to extract the whole column (array)
from the DB  and store that array to $avp.

Is there any way to extract the whole column
(base_id  in my sample) from the cached DB ?
Maybe you can provide right way to make request via
$avp(a) = $sql_cached_value(caching_name:column_name_1:key1);  ?

We expect something similar to
avp_db_query("select base_id from test","$avp(list)");
xlog("avp(list)=$(avp(list)[*])\n");


Thanks in advance !

-- 
best regards, Alexey
https://alexeyka.zantsev.com/



More information about the Users mailing list