Shared data between in perl module

Jorge Pereira jpereira at freeradius.org
Wed May 19 03:44:52 CEST 2021


Or maybe use the _Singleton Pattern_ https://www.perl.com/article/52/2013/12/11/Implementing-the-singleton-pattern-in-Perl/ <https://www.perl.com/article/52/2013/12/11/Implementing-the-singleton-pattern-in-Perl/>
--
Jorge Pereira
jpereira at freeradius.org




> On 18 May 2021, at 11:21, Alan DeKok <aland at deployingradius.com> wrote:
> 
> On May 18, 2021, at 7:52 AM, Юрий Иванов <format_hub at outlook.com> wrote:
>> I plan to implement accounting logic with the help of perl module.
>> 
>> Looks simple, but every time I should open new database connection which is not very effective in case of high load systems.
>> 
>> sub accounting {
>>   $redis = Redis->new(server => '127.0.0.1:6379', reconnect => 2);
>>   ...
>> 
>> Is there way to make some sort of "shared" variable in perl module?
> 
>  This is part of Perl:  https://perldoc.perl.org/threads::shared
> 
>> P.S. Maybe there is even some way to create some buffer array variable inside perl module which persists between perl modules so I can drop redis?
> 
>  Use the threads::shared package, and put the buffer array into a shared variable.
> 
>  Alan DeKok.
> 
> 
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html



More information about the Freeradius-Users mailing list