2017 © Pedro Peláez
 

library php-list

Lists

image

sokil/php-list

Lists

  • Monday, March 5, 2018
  • by sokil
  • Repository
  • 2 Watchers
  • 2 Stars
  • 319 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 1 % Grown

The README.md

Lists

Build Status Latest Stable Version Coverage Status Total Downloads Daily Downloads, (*1)

Installation

You can install library through Composer:, (*2)

{
    "require": {
        "sokil/php-list": "dev-master"
    }
}

Priority Map

Priority map allows you to specify priority of items and iterate through this list in order to priority., (*3)

Add elements to list with priority:, (*4)

<?php

$list = new \Sokil\DataType\PriorityMap();
$list->set('key1', 'value1', 10);
$list->set('key2', 'value2', 100);

Get elements according to priority:, (*5)

<?php
foreach($list as $key => $value) {
    echo $key . ' - ' . $value;
}

// this will print
//   key2 - value2
//   key1 - value1

Get element by key:, (*6)

<?php

$list = new \Sokil\DataType\PriorityMap();
$list->set('key1', 'value1', 10);
$list->get('key1');

Weight List

Weight list allows you to specify values and relative weights, and randomly get value according to it's weight., (*7)

Imagine that we have three database servers with ip addresses: 10.0.0.1, 10.0.0.2 and 10.0.0.3. We want to balance connections between nodes with weights 60%, 30% and 10%. So most connections goes to server 10.0.0.1, than to 10.0.0.2 and than to 10.0.0.3., (*8)

<?php

$list = new \Sokil\DataType\WeightList([
    '10.0.0.1' => 60,
    '10.0.0.2' => 30,
    '10.0.0.3' => 10,
]);

$ipAddress = $list->getRandomValue();

Now we have address on every request relatively to it's weight., (*9)

The Versions

05/03 2018

dev-master

9999999-dev

Lists

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Dmytro Sokil

14/07 2016

0.0.7

0.0.7.0

Lists

  Sources   Download

MIT

The Development Requires

by Dmytro Sokil

13/07 2016

0.0.6

0.0.6.0

Lists

  Sources   Download

MIT

The Development Requires

by Dmytro Sokil

28/11 2014

0.0.5

0.0.5.0

Lists

  Sources   Download

MIT

The Development Requires

by Dmytro Sokil

28/11 2014

0.0.4

0.0.4.0

Lists

  Sources   Download

MIT

The Development Requires

by Dmytro Sokil

28/11 2014

0.0.3

0.0.3.0

Lists

  Sources   Download

MIT

The Development Requires

by Dmytro Sokil