[OpenSIPS-Users] Reading contents of a file - OpenSIPS 3.1
Mark Allen
mark at allenclan.co.uk
Mon Nov 16 20:51:21 EST 2020
thanks - that's really helpful
On Mon, 16 Nov 2020 at 18:13, Ovidiu Sas <osas at voipembedded.com> wrote:
> Use the sql_cacher module to cache the content of the file.
> First, declare the cache that you want to use, then configure the
> sql_cacher to use the file:
> loadmodule "cachedb_local.so"
> modparam("cachedb_local", "cache_collections", "my_cache")
> modparam("cachedb_local", "cachedb_url", "local:///my_cache")
> loadmodule "sql_cacher.so"
> modparam("sql_cacher", "cache_table",
> "id=my_cache_id
> db_url=text:///tmp/opensipsdb
> cachedb_url=local:///my_cache
> table=my_table
> key=my_key
> columns=my_value
> on_demand=0")
>
> Or you can simply use the avpops module directly on the db_text file.
>
> -ovidiu
>
> https://opensips.org/docs/modules/3.1.x/cachedb_local.html
> https://opensips.org/docs/modules/3.1.x/sql_cacher.html
> https://opensips.org/docs/modules/3.1.x/avpops.html
>
> On Sun, Nov 15, 2020 at 9:49 AM Mark Allen <mark at allenclan.co.uk> wrote:
> >
> > Being a bit dense here - the documentation says to set modparams like...
> >
> > modparam("usrloc|auth_db", "db_url", "text:///tmp/opensipsdb")
> >
> > ...if I'm using a separate table with our specific info rather than,
> say, usrloc - what am I putting in as the module name?
> >
> > On Fri, 13 Nov 2020 at 16:39, Maxim Sobolev <sobomax at sippysoft.com>
> wrote:
> >>
> >> Who doubted it?! I personally think db_text is absolutely brilliant,
> cuts devtesting effort 10x easily.
> >>
> >> -Max
> >>
> >> On Fri., Nov. 13, 2020, 7:31 a.m. johan, <johan at democon.be> wrote:
> >>>
> >>> And so is the usefulness of db_text proven :-)
> >>>
> >>> On 13/11/2020 16:06, Ovidiu Sas wrote:
> >>>
> >>> Take a look at db_text and sql_cacher modules!
> >>>
> >>> Regards,
> >>> Ovidiu Sas
> >>>
> >>> On Fri, Nov 13, 2020 at 09:50 Mark Allen <mark at allenclan.co.uk> wrote:
> >>>>
> >>>> Just would like to consult the hive mind. I want to read the contents
> of a multi-line text file to be used by my OpenSIPS config. Ideally, I'll
> get a key:value CSV pair from the file and store each pair in memcache -
> e.g.
> >>>>
> >>>> file contains:
> >>>>
> >>>> a, 113
> >>>> b, 214
> >>>> c, 771
> >>>>
> >>>> read it in line by line and cache_store() with the letter as the
> attribute and the number as the value.
> >>>>
> >>>> I was thinking that I could use exec() to 'cat' the contents of the
> file, storing stdout in an AVP, and then work through that array splitting
> letter and number with a string transformation ready for cache_store().
> However, if I do this the full file contents are stored as a single string
> in the first value with "#012" added in place of the new lines.
> >>>>
> >>>> Obviously, I can use a string transform s.select{} using #012 as a
> delimiter in an intermediary step, but am I just doing this the hard way?
> Is there a better way to achieve this?
> >>>> _______________________________________________
> >>>> Users mailing list
> >>>> Users at lists.opensips.org
> >>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> >>>
> >>> --
> >>> VoIP Embedded, Inc.
> >>> http://www.voipembedded.com
> >>>
> >>> _______________________________________________
> >>> Users mailing list
> >>> Users at lists.opensips.org
> >>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> >>>
> >>> _______________________________________________
> >>> Users mailing list
> >>> Users at lists.opensips.org
> >>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> >>
> >> _______________________________________________
> >> Users mailing list
> >> Users at lists.opensips.org
> >> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> >
> > _______________________________________________
> > Users mailing list
> > Users at lists.opensips.org
> > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
>
> --
> VoIP Embedded, Inc.
> http://www.voipembedded.com
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20201116/57db7618/attachment.html>
More information about the Users
mailing list