Alexey,

You have not provided the list of columns you want to the sql_cacher config. 
Please review 
https://opensips.org/docs/modules/3.2.x/sql_cacher.html#param_cache_table.

You need to add something like:

columns=column_1 column_2 column_3

Ben Newlin

From: Users <[email protected]> on behalf of Alexey 
<[email protected]>
Date: Monday, February 12, 2024 at 1:23 AM
To: [email protected] <[email protected]>
Subject: Re: [OpenSIPS-Users] variable/avp value check
 EXTERNAL EMAIL - Please use caution with links and attachments

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:[email protected]/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

_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to