From 9d6748e2d5d3ad3fd86f169e2caa5a39e630a142 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Fri, 30 Aug 2019 15:42:27 +0200 Subject: [PATCH] TT#66052 add RedisLocation versioning 1 * location: redis entries are now fetched as 1:location: Change-Id: I5f5b3afda2d7173bf1a0a3fd6aa25145dbffcfc1 --- lib/NGCP/Panel/Utils/RedisLocationResultSet.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/NGCP/Panel/Utils/RedisLocationResultSet.pm b/lib/NGCP/Panel/Utils/RedisLocationResultSet.pm index 9200caf5d5..e40a499429 100644 --- a/lib/NGCP/Panel/Utils/RedisLocationResultSet.pm +++ b/lib/NGCP/Panel/Utils/RedisLocationResultSet.pm @@ -10,6 +10,11 @@ use Data::Dumper; use Time::HiRes qw(time); use POSIX qw(strftime); +has usrloc_path => ( + is => 'ro', + default => '1:location', +); + has _c => ( is => 'ro', isa => sub { die "$_[0] must be NGCP::Panel" unless $_[0] && ref $_[0] eq 'NGCP::Panel' }, @@ -95,7 +100,7 @@ sub find { return; } - my %entry = $self->_redis->hgetall("location:entry::$id"); + my %entry = $self->_redis->hgetall($self->usrloc_path.":entry::$id"); $entry{id} = $entry{ruid}; # deflate expires column if ($entry{expires}) { @@ -119,11 +124,11 @@ sub search { push @{ $new_rs->_rows }, $new_rs->find($filter); } elsif ($filter->{username} && $filter->{domain}) { push @{ $new_rs->_rows }, - @{ $new_rs->_rows_from_mapkey("location:usrdom::" . + @{ $new_rs->_rows_from_mapkey($self->usrloc_path.":usrdom::" . lc($filter->{username}) . ":" . lc($filter->{domain}), $filter) }; } elsif ($filter->{username}) { push @{ $new_rs->_rows }, - @{ $new_rs->_rows_from_mapkey("location:usrdom::" . + @{ $new_rs->_rows_from_mapkey($self->usrloc_path.":usrdom::" . lc($filter->{username}), $filter) }; } else { $new_rs->_scan($filter); @@ -255,7 +260,7 @@ sub _scan { $self->_rows([]); my $cursor = 0; do { - my $res = $self->_redis->scan($cursor, MATCH => "location:usrdom::$match", COUNT => 1000); + my $res = $self->_redis->scan($cursor, MATCH => $self->usrloc_path.":usrdom::$match", COUNT => 1000); $cursor = shift @{ $res }; my $mapkeys = shift @{ $res }; foreach my $mapkey (@{ $mapkeys }) {