| | 555 | |
|---|
| | 556 | my $_g_mc; |
|---|
| | 557 | my $_g_mc_id = ''; |
|---|
| | 558 | |
|---|
| | 559 | sub asset_cache_replace { |
|---|
| | 560 | my $self = shift; |
|---|
| | 561 | my ($serviceId, $assetId, $repId, $snl) = @_; |
|---|
| | 562 | my $all = $self->getNodes(['open','closed','truant']); |
|---|
| | 563 | my @nodes = sort (map { $_->ip() } ($all->items())); |
|---|
| | 564 | my $id = join(',', @nodes); |
|---|
| | 565 | if (!$_g_mc or $_g_mc_id ne $id) { |
|---|
| | 566 | $_g_mc_id = $id; |
|---|
| | 567 | $_g_mc = memcached_create(); |
|---|
| | 568 | memcached_behavior_set($_g_mc, MEMCACHED_BEHAVIOR_DISTRIBUTION(), |
|---|
| | 569 | MEMCACHED_DISTRIBUTION_CONSISTENT()); |
|---|
| | 570 | foreach my $ip (@nodes) { |
|---|
| | 571 | memcached_server_add($_g_mc, $ip, 11211); |
|---|
| | 572 | } |
|---|
| | 573 | } |
|---|
| | 574 | memcached_set($_g_mc, "$serviceId-$assetId-$repId", |
|---|
| | 575 | join(',', map { $_->id() } ($snl->items()))); |
|---|
| | 576 | } |
|---|