You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by is...@apache.org on 2018/10/09 14:47:34 UTC
[19/21] ignite git commit: IGNITE-7783: PHP thin client
http://git-wip-us.apache.org/repos/asf/ignite/blob/f28e4f3f/modules/platforms/php/composer.json
----------------------------------------------------------------------
diff --git a/modules/platforms/php/composer.json b/modules/platforms/php/composer.json
new file mode 100644
index 0000000..b07c058
--- /dev/null
+++ b/modules/platforms/php/composer.json
@@ -0,0 +1,27 @@
+{
+ "name": "apache/apache-ignite-client",
+ "type": "library",
+ "description": "PHP Client for Apache Ignite",
+ "keywords": ["apache", "ignite", "client"],
+ "homepage": "https://github.com/apache/ignite",
+ "license": "Apache-2.0",
+ "authors": [
+ ],
+ "require": {
+ "php": ">=7.2.0",
+ "ext-mbstring": "*",
+ "php-ds/php-ds": "^1.2",
+ "brick/math": "^0.7"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^7.3.1"
+ },
+ "suggest": {
+ },
+ "autoload": {
+ "psr-4": {"Apache\\Ignite\\": "src/Apache/Ignite"}
+ },
+ "autoload-dev": {
+ "psr-4": { "Apache\\Ignite\\Tests\\": "tests/" }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f28e4f3f/modules/platforms/php/examples/AuthTlsExample.php
----------------------------------------------------------------------
diff --git a/modules/platforms/php/examples/AuthTlsExample.php b/modules/platforms/php/examples/AuthTlsExample.php
new file mode 100644
index 0000000..6f5fffc
--- /dev/null
+++ b/modules/platforms/php/examples/AuthTlsExample.php
@@ -0,0 +1,129 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require_once __DIR__ . '/../vendor/autoload.php';
+
+use Apache\Ignite\Client;
+use Apache\Ignite\ClientConfiguration;
+use Apache\Ignite\Cache\CacheInterface;
+use Apache\Ignite\Exception\ClientException;
+use Apache\Ignite\Type\ObjectType;
+
+// This example demonstrates how to establish a secure connection to an Ignite node and use username/password authentication,
+// as well as basic Key-Value Queries operations for primitive types:
+// - connects to a node using TLS and providing username/password
+// - creates a cache, if it doesn't exist
+// - specifies key and value type of the cache
+// - put data of primitive types into the cache
+// - get data from the cache
+// - destroys the cache
+class AuthTlsExample
+{
+ const ENDPOINT = 'localhost:10800';
+ const USER_NAME = 'ignite';
+ const PASSWORD = 'ignite';
+
+ const TLS_CLIENT_CERT_FILE_NAME = __DIR__ . '/certs/client.pem';
+ const TLS_CA_FILE_NAME = __DIR__ . '/certs/ca.pem';
+
+ const CACHE_NAME = 'AuthTlsExample_cache';
+
+ public function start(): void
+ {
+ $client = new Client();
+ try {
+ $tlsOptions = [
+ 'local_cert' => AuthTlsExample::TLS_CLIENT_CERT_FILE_NAME,
+ 'cafile' => AuthTlsExample::TLS_CA_FILE_NAME
+ ];
+
+ $config = (new ClientConfiguration(AuthTlsExample::ENDPOINT))->
+ setUserName(AuthTlsExample::USER_NAME)->
+ setPassword(AuthTlsExample::PASSWORD)->
+ setTLSOptions($tlsOptions);
+
+ $client->connect($config);
+
+ echo("Client connected successfully (with TLS and authentication enabled)" . PHP_EOL);
+
+ $cache = $client->getOrCreateCache(AuthTlsExample::CACHE_NAME)->
+ setKeyType(ObjectType::BYTE)->
+ setValueType(ObjectType::SHORT_ARRAY);
+
+ $this->putGetData($cache);
+ $client->destroyCache(AuthTlsExample::CACHE_NAME);
+ } catch (ClientException $e) {
+ echo('ERROR: ' . $e->getMessage() . PHP_EOL);
+ } finally {
+ $client->disconnect();
+ }
+ }
+
+ private function putGetData(CacheInterface $cache): void
+ {
+ $values = [
+ 1 => $this->generateValue(1),
+ 2 => $this->generateValue(2),
+ 3 => $this->generateValue(3)
+ ];
+
+ // put values
+ foreach ($values as $key => $value) {
+ $cache->put($key, $value);
+ }
+ echo('Cache values put successfully:' . PHP_EOL);
+ foreach ($values as $key => $value) {
+ $this->printValue($key, $value);
+ }
+
+ // get and compare values
+ echo('Cache values get:' . PHP_EOL);
+ foreach ($values as $key => $value) {
+ $cacheValue = $cache->get($key);
+ $this->printValue($key, $cacheValue);
+ if (!$this->compareValues($value, $cacheValue)) {
+ echo('Unexpected cache value!' . PHP_EOL);
+ return;
+ }
+ }
+ echo('Cache values compared successfully' . PHP_EOL);
+ }
+
+ private function compareValues(array $array1, array $array2): bool
+ {
+ return count(array_diff($array1, $array2)) === 0;
+ }
+
+ private function generateValue(int $key): array
+ {
+ $length = $key + 2;
+ $result = [];
+ for ($i = 0; $i < $length; $i++) {
+ array_push($result, $key * 10 + $i);
+ }
+ return $result;
+ }
+
+ private function printValue($key, $value): void
+ {
+ echo(sprintf(' %d => [%s]%s', $key, implode(', ', $value), PHP_EOL));
+ }
+}
+
+$authTlsExample = new AuthTlsExample();
+$authTlsExample->start();
http://git-wip-us.apache.org/repos/asf/ignite/blob/f28e4f3f/modules/platforms/php/examples/CachePutGetExample.php
----------------------------------------------------------------------
diff --git a/modules/platforms/php/examples/CachePutGetExample.php b/modules/platforms/php/examples/CachePutGetExample.php
new file mode 100644
index 0000000..4d9db53
--- /dev/null
+++ b/modules/platforms/php/examples/CachePutGetExample.php
@@ -0,0 +1,184 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require_once __DIR__ . '/../vendor/autoload.php';
+
+use Apache\Ignite\Client;
+use Apache\Ignite\ClientConfiguration;
+use Apache\Ignite\Cache\CacheEntry;
+use Apache\Ignite\Query\ScanQuery;
+use Apache\Ignite\Exception\ClientException;
+use Apache\Ignite\Data\BinaryObject;
+use Apache\Ignite\Type\ObjectType;
+use Apache\Ignite\Type\ComplexObjectType;
+
+class Person
+{
+ private static $personId = 0;
+
+ public $id;
+ public $firstName;
+ public $lastName;
+ public $salary;
+
+ public function __construct(string $firstName = null, string $lastName = null, float $salary = 0)
+ {
+ $this->id = Person::generateId();
+ $this->firstName = $firstName;
+ $this->lastName = $lastName;
+ $this->salary = $salary;
+ }
+
+ public function printObject(): void
+ {
+ echo(sprintf(' %s%s', Person::class, PHP_EOL));
+ Person::printField('id', $this->id);
+ Person::printField('firstName', $this->firstName);
+ Person::printField('lastName', $this->lastName);
+ Person::printField('salary', $this->salary);
+ }
+
+ public static function generateId(): int
+ {
+ $id = Person::$personId;
+ Person::$personId++;
+ return $id;
+ }
+
+ public static function printField(string $fieldName, $fieldValue): void
+ {
+ echo(sprintf(' %s : %s%s', $fieldName, $fieldValue, PHP_EOL));
+ }
+}
+
+// This example demonstrates basic Cache, Key-Value Queries and Scan Query operations:
+// - connects to a node
+// - creates a cache, if it doesn't exist
+// - specifies key type as Integer
+// - executes different cache operations with Complex Objects and Binary Objects
+// - put several objects
+// - putAll
+// - get
+// - getAll
+// - ScanQuery
+// - destroys the cache
+class CachePutGetExample
+{
+ const ENDPOINT = '127.0.0.1:10800';
+ const CACHE_NAME = 'CachePutGetExample_person';
+
+ private $personCache;
+ private $binaryObjectCache;
+ private $personObjectType;
+
+ public function start(): void
+ {
+ $client = new Client();
+ try {
+ $client->connect(new ClientConfiguration(CachePutGetExample::ENDPOINT));
+
+ $this->personObjectType = (new ComplexObjectType())->
+ setFieldType('id', ObjectType::INTEGER);
+
+ $this->personCache = $client->getOrCreateCache(CachePutGetExample::CACHE_NAME)->
+ setKeyType(ObjectType::INTEGER)->
+ setValueType($this->personObjectType);
+
+ $this->binaryObjectCache = $client->getCache(CachePutGetExample::CACHE_NAME)->
+ setKeyType(ObjectType::INTEGER);
+
+ $this->putComplexObjects();
+ $this->putAllBinaryObjects();
+
+ $this->getAllComplexObjects();
+ $this->getBinaryObjects();
+
+ $this->scanQuery();
+
+ $client->destroyCache(CachePutGetExample::CACHE_NAME);
+ } catch (ClientException $e) {
+ echo('ERROR: ' . $e->getMessage() . PHP_EOL);
+ } finally {
+ $client->disconnect();
+ }
+ }
+
+ private function putComplexObjects(): void
+ {
+ $person1 = new Person('John', 'Doe', 1000);
+ $person2 = new Person('Jane', 'Roe', 2000);
+
+ $this->personCache->put($person1->id, $person1);
+ $this->personCache->put($person2->id, $person2);
+
+ echo('Complex Objects put successfully' . PHP_EOL);
+ }
+
+ private function putAllBinaryObjects(): void
+ {
+ // create binary object from scratch
+ $personBinaryObject1 = (new BinaryObject(Person::class))->
+ setField('id', Person::generateId(), ObjectType::INTEGER)->
+ setField('firstName', 'Mary')->
+ setField('lastName', 'Major')->
+ setField('salary', 1500, ObjectType::DOUBLE);
+
+ // create binary object from complex object
+ $personBinaryObject2 = BinaryObject::fromObject(
+ new Person('Richard', 'Miles', 800), $this->personObjectType);
+
+ $this->binaryObjectCache->putAll([
+ new CacheEntry($personBinaryObject1->getField('id'), $personBinaryObject1),
+ new CacheEntry($personBinaryObject2->getField('id'), $personBinaryObject2)
+ ]);
+
+ echo('Binary Objects put successfully using putAll()' . PHP_EOL);
+ }
+
+ private function getAllComplexObjects(): void
+ {
+ $persons = $this->personCache->getAll([0, 1]);
+ echo('Complex Objects getAll:' . PHP_EOL);
+ foreach ($persons as $person) {
+ $person->getValue()->printObject();
+ }
+ }
+
+ private function getBinaryObjects(): void
+ {
+ $personBinaryObject = $this->binaryObjectCache->get(2);
+ echo('Binary Object get:' . PHP_EOL);
+ echo(sprintf(" %s%s", $personBinaryObject->getTypeName(), PHP_EOL));
+ foreach ($personBinaryObject->getFieldNames() as $fieldName) {
+ $fieldValue = $personBinaryObject->getField($fieldName);
+ Person::printField($fieldName, $fieldValue);
+ }
+ }
+
+ private function scanQuery(): void
+ {
+ $cursor = $this->personCache->query(new ScanQuery());
+ echo('Scan query results:' . PHP_EOL);
+ foreach ($cursor as $cacheEntry) {
+ $cacheEntry->getValue()->printObject();
+ }
+ }
+}
+
+$cachePutGetExample = new CachePutGetExample();
+$cachePutGetExample->start();
http://git-wip-us.apache.org/repos/asf/ignite/blob/f28e4f3f/modules/platforms/php/examples/FailoverExample.php
----------------------------------------------------------------------
diff --git a/modules/platforms/php/examples/FailoverExample.php b/modules/platforms/php/examples/FailoverExample.php
new file mode 100644
index 0000000..7598511
--- /dev/null
+++ b/modules/platforms/php/examples/FailoverExample.php
@@ -0,0 +1,67 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require_once __DIR__ . '/../vendor/autoload.php';
+
+use Apache\Ignite\Client;
+use Apache\Ignite\ClientConfiguration;
+use Apache\Ignite\Exception\ClientException;
+use Apache\Ignite\Exception\NoConnectionException;
+use Apache\Ignite\Exception\OperationStatusUnknownException;
+
+const ENDPOINT1 = 'localhost:10800';
+const ENDPOINT2 = 'localhost:10801';
+const ENDPOINT3 = 'localhost:10802';
+
+const CACHE_NAME = 'test_cache';
+
+// This example demonstrates failover behavior of the client
+// - configures the client to connect to a set of nodes
+// - connects to a node
+// - executes an operation with Ignite server in a cycle (10 operations with 5 seconds pause) and finishes
+// - if connection is broken, the client automatically tries to reconnect to another node
+// - if not possible to connect to any nodes, the example finishes
+function connectClient() {
+ $client = new Client();
+ $client->setDebug(true);
+ try {
+ $clientConfiguration = new ClientConfiguration(ENDPOINT1, ENDPOINT2, ENDPOINT3);
+ // connect to Ignite node
+ $client->connect($clientConfiguration);
+ echo("Client connected successfully" . PHP_EOL);
+ for ($i = 0; $i < 10; $i++) {
+ try {
+ $client->getOrCreateCache(CACHE_NAME);
+ sleep(5);
+ } catch (OperationStatusUnknownException $e) {
+ // Status of the operation is unknown,
+ // a real application may repeat the operation if necessary
+ }
+ }
+ } catch (NoConnectionException $e) {
+ // The client is disconnected, all further operation with Ignite server fail till the client is connected again.
+ // A real application may recall $client->connect() with the same or different list of Ignite nodes.
+ echo('ERROR: ' . $e->getMessage() . PHP_EOL);
+ } catch (ClientException $e) {
+ echo('ERROR: ' . $e->getMessage() . PHP_EOL);
+ } finally {
+ $client->disconnect();
+ }
+}
+
+connectClient();
http://git-wip-us.apache.org/repos/asf/ignite/blob/f28e4f3f/modules/platforms/php/examples/SqlExample.php
----------------------------------------------------------------------
diff --git a/modules/platforms/php/examples/SqlExample.php b/modules/platforms/php/examples/SqlExample.php
new file mode 100644
index 0000000..db0baf6
--- /dev/null
+++ b/modules/platforms/php/examples/SqlExample.php
@@ -0,0 +1,237 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require_once __DIR__ . '/../vendor/autoload.php';
+
+use Apache\Ignite\Client;
+use Apache\Ignite\ClientConfiguration;
+use Apache\Ignite\Exception\ClientException;
+use Apache\Ignite\Cache\CacheInterface;
+use Apache\Ignite\Cache\CacheConfiguration;
+use Apache\Ignite\Query\SqlFieldsQuery;
+
+// This example shows primary APIs to use with Ignite as with an SQL database:
+// - connects to a node
+// - creates a cache, if it doesn't exist
+// - creates tables (CREATE TABLE)
+// - creates indices (CREATE INDEX)
+// - writes data of primitive types into the tables (INSERT INTO table)
+// - reads data from the tables (SELECT ...)
+// - deletes tables (DROP TABLE)
+// - destroys the cache
+class SqlExample {
+ const ENDPOINT = '127.0.0.1:10800';
+
+ const COUNTRY_CACHE_NAME = 'Country';
+ const CITY_CACHE_NAME = 'City';
+ const COUNTRY_LANGUAGE_CACHE_NAME = 'CountryLng';
+ const DUMMY_CACHE_NAME = 'SqlExample_Dummy';
+
+ public function start(): void
+ {
+ $client = new Client();
+ try {
+ $client->connect(new ClientConfiguration(SqlExample::ENDPOINT));
+
+ $cache = $client->getOrCreateCache(
+ SqlExample::DUMMY_CACHE_NAME,
+ (new CacheConfiguration())->setSqlSchema('PUBLIC'));
+
+ $this->createDatabaseObjects($cache);
+ $this->insertData($cache);
+
+ $countryCache = $client->getCache(SqlExample::COUNTRY_CACHE_NAME);
+ $cityCache = $client->getCache(SqlExample::CITY_CACHE_NAME);
+
+ $this->getMostPopulatedCities($countryCache);
+ $this->getTopCitiesInThreeCountries($cityCache);
+ $this->getCityDetails($cityCache, 5);
+
+ $this->deleteDatabaseObjects($cache);
+ $client->destroyCache(SqlExample::DUMMY_CACHE_NAME);
+ } catch (ClientException $e) {
+ echo('ERROR: ' . $e->getMessage() . PHP_EOL);
+ } finally {
+ $client->disconnect();
+ }
+ }
+
+ public function createDatabaseObjects(CacheInterface $cache): void
+ {
+ $createCountryTable = 'CREATE TABLE Country (' .
+ 'Code CHAR(3) PRIMARY KEY,' .
+ 'Name CHAR(52),' .
+ 'Continent CHAR(50),' .
+ 'Region CHAR(26),' .
+ 'SurfaceArea DECIMAL(10,2),' .
+ 'IndepYear SMALLINT(6),' .
+ 'Population INT(11),' .
+ 'LifeExpectancy DECIMAL(3,1),' .
+ 'GNP DECIMAL(10,2),' .
+ 'GNPOld DECIMAL(10,2),' .
+ 'LocalName CHAR(45),' .
+ 'GovernmentForm CHAR(45),' .
+ 'HeadOfState CHAR(60),' .
+ 'Capital INT(11),' .
+ 'Code2 CHAR(2)' .
+ ') WITH "template=partitioned, backups=1, CACHE_NAME=' . SqlExample::COUNTRY_CACHE_NAME . '"';
+
+ $createCityTable = 'CREATE TABLE City (' .
+ 'ID INT(11),' .
+ 'Name CHAR(35),' .
+ 'CountryCode CHAR(3),' .
+ 'District CHAR(20),' .
+ 'Population INT(11),' .
+ 'PRIMARY KEY (ID, CountryCode)' .
+ ') WITH "template=partitioned, backups=1, affinityKey=CountryCode, CACHE_NAME=' . SqlExample::CITY_CACHE_NAME . '"';
+
+ $createCountryLanguageTable = 'CREATE TABLE CountryLanguage (' .
+ 'CountryCode CHAR(3),' .
+ 'Language CHAR(30),' .
+ 'IsOfficial CHAR(2),' .
+ 'Percentage DECIMAL(4,1),' .
+ 'PRIMARY KEY (CountryCode, Language)' .
+ ') WITH "template=partitioned, backups=1, affinityKey=CountryCode, CACHE_NAME=' . SqlExample::COUNTRY_LANGUAGE_CACHE_NAME . '"';
+
+ // create tables
+ $cache->query(new SqlFieldsQuery($createCountryTable))->getAll();
+ $cache->query(new SqlFieldsQuery($createCityTable))->getAll();
+ $cache->query(new SqlFieldsQuery($createCountryLanguageTable))->getAll();
+
+ // create indices
+ $cache->query(new SqlFieldsQuery(
+ 'CREATE INDEX idx_country_code ON city (CountryCode)'))->getAll();
+ $cache->query(new SqlFieldsQuery(
+ 'CREATE INDEX idx_lang_country_code ON CountryLanguage (CountryCode)'))->getAll();
+
+ echo('Database objects created' . PHP_EOL);
+ }
+
+ private function insertData(CacheInterface $cache): void
+ {
+ $cities = [
+ ['New York', 'USA', 'New York', 8008278],
+ ['Los Angeles', 'USA', 'California', 3694820],
+ ['Chicago', 'USA', 'Illinois', 2896016],
+ ['Houston', 'USA', 'Texas', 1953631],
+ ['Philadelphia', 'USA', 'Pennsylvania', 1517550],
+ ['Moscow', 'RUS', 'Moscow (City)', 8389200],
+ ['St Petersburg', 'RUS', 'Pietari', 4694000],
+ ['Novosibirsk', 'RUS', 'Novosibirsk', 1398800],
+ ['Nizni Novgorod', 'RUS', 'Nizni Novgorod', 1357000],
+ ['Jekaterinburg', 'RUS', 'Sverdlovsk', 1266300],
+ ['Shanghai', 'CHN', 'Shanghai', 9696300],
+ ['Peking', 'CHN', 'Peking', 7472000],
+ ['Chongqing', 'CHN', 'Chongqing', 6351600],
+ ['Tianjin', 'CHN', 'Tianjin', 5286800],
+ ['Wuhan', 'CHN', 'Hubei', 4344600]
+ ];
+
+ $cityQuery = new SqlFieldsQuery(
+ 'INSERT INTO City(ID, Name, CountryCode, District, Population) VALUES (?, ?, ?, ?, ?)');
+
+ for ($i = 0; $i < count($cities); $i++) {
+ $cache->query($cityQuery->setArgs($i, ...$cities[$i]))->getAll();
+ }
+
+ $countries = [
+ ['USA', 'United States', 'North America', 'North America',
+ 9363520.00, 1776, 278357000, 77.1, 8510700.00, 8110900.00,
+ 'United States', 'Federal Republic', 'George W. Bush', 3813, 'US'],
+ ['RUS', 'Russian Federation', 'Europe', 'Eastern Europe',
+ 17075400.00, 1991, 146934000, 67.2, 276608.00, 442989.00,
+ 'Rossija', 'Federal Republic', 'Vladimir Putin', 3580, 'RU'],
+ ['CHN', 'China', 'Asia', 'Eastern Asia',
+ 9572900.00, -1523, 1277558000, 71.4, 982268.00, 917719.00,
+ 'Zhongquo', 'PeoplesRepublic', 'Jiang Zemin', 1891, 'CN']
+ ];
+
+ $countryQuery = new SqlFieldsQuery('INSERT INTO Country(' .
+ 'Code, Name, Continent, Region, SurfaceArea,' .
+ 'IndepYear, Population, LifeExpectancy, GNP, GNPOld,' .
+ 'LocalName, GovernmentForm, HeadOfState, Capital, Code2)' .
+ 'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
+
+ foreach ($countries as $country) {
+ $cache->query($countryQuery->setArgs(...$country))->getAll();
+ }
+
+ echo('Data are inserted' . PHP_EOL);
+ }
+
+ private function getMostPopulatedCities(CacheInterface $countryCache): void
+ {
+ $query = new SqlFieldsQuery(
+ 'SELECT name, population FROM City ORDER BY population DESC LIMIT 10');
+
+ $cursor = $countryCache->query($query);
+
+ echo('10 Most Populated Cities:' . PHP_EOL);
+
+ foreach ($cursor as $row) {
+ echo(sprintf(' %d people live in %s%s', $row[1], $row[0], PHP_EOL));
+ }
+ }
+
+ private function getTopCitiesInThreeCountries(CacheInterface $countryCache): void
+ {
+ $query = new SqlFieldsQuery(
+ "SELECT country.name, city.name, MAX(city.population) as max_pop FROM country
+ JOIN city ON city.countrycode = country.code
+ WHERE country.code IN ('USA','RUS','CHN')
+ GROUP BY country.name, city.name ORDER BY max_pop DESC LIMIT 3");
+
+ $cursor = $countryCache->query($query);
+
+ echo('3 Most Populated Cities in US, RUS and CHN:' . PHP_EOL);
+
+ foreach ($cursor->getAll() as $row) {
+ echo(sprintf(' %d people live in %s, %s%s', $row[2], $row[1], $row[0], PHP_EOL));
+ }
+ }
+
+ private function getCityDetails(CacheInterface $cityCache, int $cityId): void
+ {
+ $query = (new SqlFieldsQuery('SELECT * FROM City WHERE id = ?'))->
+ setArgs($cityId)->
+ setIncludeFieldNames(true);
+
+ $cursor = $cityCache->query($query);
+
+ $fieldNames = $cursor->getFieldNames();
+
+ foreach ($cursor->getAll() as $city) {
+ echo('City Info:' . PHP_EOL);
+ for ($i = 0; $i < count($fieldNames); $i++) {
+ echo(sprintf(' %s : %s%s', $fieldNames[$i], $city[$i], PHP_EOL));
+ }
+ }
+ }
+
+ private function deleteDatabaseObjects($cache): void
+ {
+ $cache->query(new SqlFieldsQuery('DROP TABLE IF EXISTS Country'))->getAll();
+ $cache->query(new SqlFieldsQuery('DROP TABLE IF EXISTS City'))->getAll();
+ $cache->query(new SqlFieldsQuery('DROP TABLE IF EXISTS CountryLanguage'))->getAll();
+
+ echo('Database objects dropped' . PHP_EOL);
+ }
+}
+
+$sqlExample = new SqlExample();
+$sqlExample->start();
http://git-wip-us.apache.org/repos/asf/ignite/blob/f28e4f3f/modules/platforms/php/examples/SqlQueryEntriesExample.php
----------------------------------------------------------------------
diff --git a/modules/platforms/php/examples/SqlQueryEntriesExample.php b/modules/platforms/php/examples/SqlQueryEntriesExample.php
new file mode 100644
index 0000000..a02733e
--- /dev/null
+++ b/modules/platforms/php/examples/SqlQueryEntriesExample.php
@@ -0,0 +1,127 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require_once __DIR__ . '/../vendor/autoload.php';
+
+use Apache\Ignite\Client;
+use Apache\Ignite\ClientConfiguration;
+use Apache\Ignite\Cache\CacheConfiguration;
+use Apache\Ignite\Cache\QueryEntity;
+use Apache\Ignite\Cache\QueryField;
+use Apache\Ignite\Type\ObjectType;
+use Apache\Ignite\Type\ComplexObjectType;
+use Apache\Ignite\Exception\ClientException;
+use Apache\Ignite\Query\SqlQuery;
+
+class Person
+{
+ private static $personId = 0;
+
+ public $id;
+ public $firstName;
+ public $lastName;
+ public $salary;
+
+ public function __construct(string $firstName = null, string $lastName = null, float $salary = 0)
+ {
+ $this->id = Person::generateId();
+ $this->firstName = $firstName;
+ $this->lastName = $lastName;
+ $this->salary = $salary;
+ }
+
+ public static function generateId(): int
+ {
+ $id = Person::$personId;
+ Person::$personId++;
+ return $id;
+ }
+}
+
+// This example demonstrates basic Cache, Key-Value Queries and SQL Query operations:
+// - connects to a node
+// - creates a cache from CacheConfiguration, if it doesn't exist
+// - writes data of primitive and Complex Object types into the cache using Key-Value put operation
+// - reads data from the cache using SQL Query
+// - destroys the cache
+class SqlQueryEntriesExample {
+ const ENDPOINT = '127.0.0.1:10800';
+ const PERSON_CACHE_NAME = 'SqlQueryEntriesExample_person';
+
+ private $cache;
+
+ public function start(): void
+ {
+ $client = new Client();
+ try {
+ $client->connect(new ClientConfiguration(self::ENDPOINT));
+
+ $cacheCfg = (new CacheConfiguration())->
+ setQueryEntities(
+ (new QueryEntity())->
+ setValueTypeName('Person')->
+ setFields(
+ new QueryField('id', 'java.lang.Integer'),
+ new QueryField('firstName', 'java.lang.String'),
+ new QueryField('lastName', 'java.lang.String'),
+ new QueryField('salary', 'java.lang.Double')
+ ));
+ $this->cache = $client->getOrCreateCache(self::PERSON_CACHE_NAME, $cacheCfg)->
+ setKeyType(ObjectType::INTEGER)->
+ setValueType((new ComplexObjectType())->
+ setFieldType('id', ObjectType::INTEGER));
+
+ $this->generateData();
+
+ $sqlCursor = $this->cache->query(
+ (new SqlQuery('Person', 'salary > ? and salary <= ?'))->
+ setArgs(900.0, 1600.0));
+
+ echo('SqlQuery results (salary between 900 and 1600):' . PHP_EOL);
+ foreach ($sqlCursor as $cacheEntry) {
+ $person = $cacheEntry->getValue();
+ echo(sprintf(' name: %s %s, salary: %.2f %s',
+ $person->firstName, $person->lastName, $person->salary, PHP_EOL));
+ }
+
+ $client->destroyCache(self::PERSON_CACHE_NAME);
+ } catch (ClientException $e) {
+ echo('ERROR: ' . $e->getMessage() . PHP_EOL);
+ } finally {
+ $client->disconnect();
+ }
+ }
+
+ private function generateData(): void
+ {
+ $persons = [
+ ['John', 'Doe', 1000.0],
+ ['Jane', 'Roe', 2000.0],
+ ['Mary', 'Major', 1500.0],
+ ['Richard', 'Miles', 800.0]
+ ];
+ foreach ($persons as $data) {
+ $person = new Person(...$data);
+ $this->cache->put($person->id, $person);
+ }
+ echo('Data is generated' . PHP_EOL);
+ }
+}
+
+$sqlQueryEntriesExample = new SqlQueryEntriesExample();
+$sqlQueryEntriesExample->start();
http://git-wip-us.apache.org/repos/asf/ignite/blob/f28e4f3f/modules/platforms/php/examples/certs/ca.pem
----------------------------------------------------------------------
diff --git a/modules/platforms/php/examples/certs/ca.pem b/modules/platforms/php/examples/certs/ca.pem
new file mode 100644
index 0000000..ba90793
--- /dev/null
+++ b/modules/platforms/php/examples/certs/ca.pem
@@ -0,0 +1,32 @@
+-----BEGIN CERTIFICATE-----
+MIIFfzCCA2egAwIBAgIJAIH05meRt7kjMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV
+BAYTAkZSMQowCAYDVQQIDAEuMQowCAYDVQQHDAEuMSMwIQYDVQQKDBpBQ01FIFNp
+Z25pbmcgQXV0aG9yaXR5IEluYzEKMAgGA1UEAwwBLjAeFw0xODA0MTIyMDUxMDFa
+Fw0yODA0MDkyMDUxMDFaMFYxCzAJBgNVBAYTAkZSMQowCAYDVQQIDAEuMQowCAYD
+VQQHDAEuMSMwIQYDVQQKDBpBQ01FIFNpZ25pbmcgQXV0aG9yaXR5IEluYzEKMAgG
+A1UEAwwBLjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMoilf6lWZt8
+F+QkZj2zW8PTEiOzqjLDCmEhnoVOPXAbCucaHuqQfK8xHL2FjlkeRWO1egzXBQ/V
+K+p2+ck/1D98qL8gYfR8Zf1WUUkgBYjnch9r+BPqIjSwBD8e3HyTIq+DGQ8tYqh0
+1GtP6tooZYF2VBKu7aY69vOOgM16k+2GLR7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ZH0y3JF2eCcVXPPq6M6qM7W2IziArsZs22tkos2ARaDDU8ekmsEOH9SNphVICAet
+AT6b8YyOutTXO4LIN1TUeXmeKMpOAA2+YNCp+/OxbzkqvZxYuvbBtoSiIfrHyW4k
+rE0rRTYpB1Mk7R4+hwPnJim1OvZ+vLeLzvgGIyZKKiku2bp0YB8KGsAchnnJVlyo
+Oca/YSkKIBYCiQjxg5rX1/ZonhAkRbuqzmQdb9bJoGoN8kUdN9wvZHC3YPtox1Nd
+GoJSdO3MNkK5EwafrMAGh2Jmxg==
+-----END CERTIFICATE-----
http://git-wip-us.apache.org/repos/asf/ignite/blob/f28e4f3f/modules/platforms/php/examples/certs/client.pem
----------------------------------------------------------------------
diff --git a/modules/platforms/php/examples/certs/client.pem b/modules/platforms/php/examples/certs/client.pem
new file mode 100644
index 0000000..8016ff8
--- /dev/null
+++ b/modules/platforms/php/examples/certs/client.pem
@@ -0,0 +1,81 @@
+-----BEGIN CERTIFICATE-----
+MIIFJTCCAw0CAQEwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCRlIxCjAIBgNV
+BAgMAS4xCjAIBgNVBAcMAS4xIzAhBgNVBAoMGkFDTUUgU2lnbmluZyBBdXRob3Jp
+dHkgSW5jMQowCAYDVQQDDAEuMB4XDTE4MDQxMjIwNTEwNFoXDTI4MDQwOTIwNTEw
+NFowWzELMAkGA1UEBhMCRlIxCjAIBgNVBAgMAS4xCjAIBgNVBAcMAS4xIzAhBgNV
+BAoMGkFDTUUgU2lnbmluZyBBdXRob3JpdHkgSW5jMQ8wDQYDVQQDDAZDTElFTlQw
+ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCp1yTtzT01KDx6qyidy4GQ
+C/NbPcOkPHYYfTPkPy4xvdfPfx0FHBHxY5iqg7V2q5dbpVH1NOablC/sWOjwMXlQ
+Hs0M48Q0SRXgJA2a4wqKMfpJ6q8fxVbFENmm8d7YA3dXq6KxXq5yDxCy7pZk/ILP
+CbOob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aGQmMbAYgF7J79VcvN
+CJ1qZvvtSCSnWdMGlhs5zHzjCqk9sywtxRB8XJpp19cM7oTl4PU+ditoGTRlo0Ea
+cMuqdfg/SH/VExUyJzjyFKI5qKUnaTa83PZz4h0kt48oa4tlXzwBVKZYy/77qfQk
+ajH+THYPZ+32iDEVCpiJ9Cg8yTWGT7VxtgFRvEOBPY28T6zenl9Djl8omCOAz07a
+Ozq7QkTy4L0eCZrQ1BPHcmulHUuL+tZqKRukyBrtkTPanZEOHZ5RTfF32BVL
+-----END RSA PRIVATE KEY-----
http://git-wip-us.apache.org/repos/asf/ignite/blob/f28e4f3f/modules/platforms/php/examples/certs/keystore.jks
----------------------------------------------------------------------
diff --git a/modules/platforms/php/examples/certs/keystore.jks b/modules/platforms/php/examples/certs/keystore.jks
new file mode 100644
index 0000000..1da610f
Binary files /dev/null and b/modules/platforms/php/examples/certs/keystore.jks differ
http://git-wip-us.apache.org/repos/asf/ignite/blob/f28e4f3f/modules/platforms/php/examples/certs/truststore.jks
----------------------------------------------------------------------
diff --git a/modules/platforms/php/examples/certs/truststore.jks b/modules/platforms/php/examples/certs/truststore.jks
new file mode 100644
index 0000000..4d25cf7
Binary files /dev/null and b/modules/platforms/php/examples/certs/truststore.jks differ
http://git-wip-us.apache.org/repos/asf/ignite/blob/f28e4f3f/modules/platforms/php/src/Apache/Ignite/Cache/CacheConfiguration.php
----------------------------------------------------------------------
diff --git a/modules/platforms/php/src/Apache/Ignite/Cache/CacheConfiguration.php b/modules/platforms/php/src/Apache/Ignite/Cache/CacheConfiguration.php
new file mode 100644
index 0000000..e4a7ad6
--- /dev/null
+++ b/modules/platforms/php/src/Apache/Ignite/Cache/CacheConfiguration.php
@@ -0,0 +1,1011 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Ignite\Cache;
+
+use Apache\Ignite\Type\ObjectType;
+use Apache\Ignite\Type\ObjectArrayType;
+use Apache\Ignite\Type\ComplexObjectType;
+use Apache\Ignite\Exception\ClientException;
+use Apache\Ignite\Internal\Binary\MessageBuffer;
+use Apache\Ignite\Internal\Binary\BinaryUtils;
+use Apache\Ignite\Internal\Binary\BinaryCommunicator;
+use Apache\Ignite\Internal\Utils\ArgumentChecker;
+
+/**
+ * Class representing Ignite cache configuration on a server.
+ *
+ * All configuration settings are optional and have defaults which are defined on a server side.
+ *
+ * See Apache Ignite documentation for details of every configuration setting.
+ */
+class CacheConfiguration
+{
+ const PROP_NAME = 0;
+ const PROP_CACHE_MODE = 1;
+ const PROP_ATOMICITY_MODE = 2;
+ const PROP_BACKUPS = 3;
+ const PROP_WRITE_SYNCHRONIZATION_MODE = 4;
+ const PROP_COPY_ON_READ = 5;
+ const PROP_READ_FROM_BACKUP = 6;
+ const PROP_DATA_REGION_NAME = 100;
+ const PROP_IS_ONHEAP_CACHE_ENABLED = 101;
+ const PROP_QUERY_ENTITY = 200;
+ const PROP_QUERY_PARALLELISM = 201;
+ const PROP_QUERY_DETAIL_METRICS_SIZE = 202;
+ const PROP_SQL_SCHEMA = 203;
+ const PROP_SQL_INDEX_INLINE_MAX_SIZE = 204;
+ const PROP_SQL_ESCAPE_ALL = 205;
+ const PROP_MAX_QUERY_ITERATORS = 206;
+ const PROP_REBALANCE_MODE = 300;
+ const PROP_REBALANCE_DELAY = 301;
+ const PROP_REBALANCE_TIMEOUT = 302;
+ const PROP_REBALANCE_BATCH_SIZE = 303;
+ const PROP_REBALANCE_BATCHES_PREFETCH_COUNT = 304;
+ const PROP_REBALANCE_ORDER = 305;
+ const PROP_REBALANCE_THROTTLE = 306;
+ const PROP_GROUP_NAME = 400;
+ const PROP_CACHE_KEY_CONFIGURATION = 401;
+ const PROP_DEFAULT_LOCK_TIMEOUT = 402;
+ const PROP_MAX_CONCURRENT_ASYNC_OPS = 403;
+ const PROP_PARTITION_LOSS_POLICY = 404;
+ const PROP_EAGER_TTL = 405;
+ const PROP_STATISTICS_ENABLED = 406;
+
+ /** @name AtomicityMode
+ * @anchor AtomicityMode
+ * @{
+ */
+ const ATOMICITY_MODE_TRANSACTIONAL = 0;
+ const ATOMICITY_MODE_ATOMIC = 1;
+ /** @} */ // end of AtomicityMode
+
+ /** @name CacheMode
+ * @anchor CacheMode
+ * @{
+ */
+ const CACHE_MODE_LOCAL = 0;
+ const CACHE_MODE_REPLICATED = 1;
+ const CACHE_MODE_PARTITIONED = 2;
+ /** @} */ // end of CacheMode
+
+ /** @name PartitionLossPolicy
+ * @anchor PartitionLossPolicy
+ * @{
+ */
+ const PARTITION_LOSS_POLICY_READ_ONLY_SAFE = 0;
+ const PARTITION_LOSS_POLICY_READ_ONLY_ALL = 1;
+ const PARTITION_LOSS_POLICY_READ_WRITE_SAFE = 2;
+ const PARTITION_LOSS_POLICY_READ_WRITE_ALL = 3;
+ const PARTITION_LOSS_POLICY_IGNORE = 4;
+ /** @} */ // end of PartitionLossPolicy
+
+ /** @name RebalanceMode
+ * @anchor RebalanceMode
+ * @{
+ */
+ const REABALANCE_MODE_SYNC = 0;
+ const REABALANCE_MODE_ASYNC = 1;
+ const REABALANCE_MODE_NONE = 2;
+ /** @} */ // end of RebalanceMode
+
+ /** @name WriteSynchronizationMode
+ * @anchor WriteSynchronizationMode
+ * @{
+ */
+ const WRITE_SYNC_MODE_FULL_SYNC = 0;
+ const WRITE_SYNC_MODE_FULL_ASYNC = 1;
+ const WRITE_SYNC_MODE_PRIMARY_SYNC = 2;
+ /** @} */ // end of WriteSynchronizationMode
+
+ private $properties;
+ private static $propInfo;
+
+ /**
+ * Public CacheConfiguration constructor.
+ */
+ public function __construct()
+ {
+ $this->properties = [];
+ }
+
+ /**
+ *
+ *
+ * @param string $name
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setName(string $name): CacheConfiguration
+ {
+ $this->properties[self::PROP_NAME] = $name;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return string|null
+ */
+ public function getName(): ?string
+ {
+ return $this->getProperty(self::PROP_NAME);
+ }
+
+ /**
+ *
+ *
+ * @param int $atomicityMode one of @ref AtomicityMode constants.
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ *
+ * @throws ClientException if error.
+ */
+ public function setAtomicityMode(int $atomicityMode): CacheConfiguration
+ {
+ ArgumentChecker::hasValueFrom(
+ $atomicityMode, 'atomicityMode', false, [self::ATOMICITY_MODE_TRANSACTIONAL, self::ATOMICITY_MODE_ATOMIC]);
+ $this->properties[self::PROP_ATOMICITY_MODE] = $atomicityMode;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return int|null
+ */
+ public function getAtomicityMode(): ?int
+ {
+ return $this->getProperty(self::PROP_ATOMICITY_MODE);
+ }
+
+ /**
+ *
+ *
+ * @param int $backups
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setBackups(int $backups): CacheConfiguration
+ {
+ $this->properties[self::PROP_BACKUPS] = $backups;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return int|null
+ */
+ public function getBackups(): ?int
+ {
+ return $this->getProperty(self::PROP_BACKUPS);
+ }
+
+ /**
+ *
+ *
+ * @param int $cacheMode one of @ref CacheMode constants.
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ *
+ * @throws ClientException if error.
+ */
+ public function setCacheMode(int $cacheMode): CacheConfiguration
+ {
+ ArgumentChecker::hasValueFrom(
+ $cacheMode,
+ 'cacheMode',
+ false,
+ [self::CACHE_MODE_LOCAL, self::CACHE_MODE_REPLICATED, self::CACHE_MODE_PARTITIONED]);
+ $this->properties[self::PROP_CACHE_MODE] = $cacheMode;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return int|null
+ */
+ public function getCacheMode(): ?int
+ {
+ return $this->getProperty(self::PROP_CACHE_MODE);
+ }
+
+ /**
+ *
+ *
+ * @param bool $copyOnRead
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setCopyOnRead(bool $copyOnRead): CacheConfiguration
+ {
+ $this->properties[self::PROP_COPY_ON_READ] = $copyOnRead;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return bool|null
+ */
+ public function getCopyOnRead(): ?bool
+ {
+ return $this->getProperty(self::PROP_COPY_ON_READ);
+ }
+
+ /**
+ *
+ *
+ * @param string|null $dataRegionName
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setDataRegionName(?string $dataRegionName): CacheConfiguration
+ {
+ $this->properties[self::PROP_DATA_REGION_NAME] = $dataRegionName;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return string|null
+ */
+ public function getDataRegionName(): ?string
+ {
+ return $this->getProperty(self::PROP_DATA_REGION_NAME);
+ }
+
+ /**
+ *
+ *
+ * @param bool $eagerTtl
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setEagerTtl(bool $eagerTtl): CacheConfiguration
+ {
+ $this->properties[self::PROP_EAGER_TTL] = $eagerTtl;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return bool|null
+ */
+ public function getEagerTtl(): ?bool
+ {
+ return $this->getProperty(self::PROP_EAGER_TTL);
+ }
+
+ /**
+ *
+ *
+ * @param bool $statisticsEnabled
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setStatisticsEnabled(bool $statisticsEnabled): CacheConfiguration
+ {
+ $this->properties[self::PROP_STATISTICS_ENABLED] = $statisticsEnabled;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return bool|null
+ */
+ public function getStatisticsEnabled(): ?bool
+ {
+ return $this->getProperty(self::PROP_STATISTICS_ENABLED);
+ }
+
+ /**
+ *
+ *
+ * @param string|null $groupName
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setGroupName(?string $groupName): CacheConfiguration
+ {
+ $this->properties[self::PROP_GROUP_NAME] = $groupName;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return string|null
+ */
+ public function getGroupName(): ?string
+ {
+ return $this->getProperty(self::PROP_GROUP_NAME);
+ }
+
+ /**
+ *
+ *
+ * @param float $lockTimeout
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setDefaultLockTimeout(float $lockTimeout): CacheConfiguration
+ {
+ $this->properties[self::PROP_DEFAULT_LOCK_TIMEOUT] = $lockTimeout;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return float|null
+ */
+ public function getDefaultLockTimeout(): ?float
+ {
+ return $this->getProperty(self::PROP_DEFAULT_LOCK_TIMEOUT);
+ }
+
+ /**
+ *
+ *
+ * @param int $maxConcurrentAsyncOperations
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setMaxConcurrentAsyncOperations(int $maxConcurrentAsyncOperations): CacheConfiguration
+ {
+ $this->properties[self::PROP_MAX_CONCURRENT_ASYNC_OPS] = $maxConcurrentAsyncOperations;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return int|null
+ */
+ public function getMaxConcurrentAsyncOperations(): ?int
+ {
+ return $this->getProperty(self::PROP_MAX_CONCURRENT_ASYNC_OPS);
+ }
+
+ /**
+ *
+ *
+ * @param int $maxQueryIterators
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setMaxQueryIterators(int $maxQueryIterators): CacheConfiguration
+ {
+ $this->properties[self::PROP_MAX_QUERY_ITERATORS] = $maxQueryIterators;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return int|null
+ */
+ public function getMaxQueryIterators(): ?int
+ {
+ return $this->getProperty(self::PROP_MAX_QUERY_ITERATORS);
+ }
+
+ /**
+ *
+ *
+ * @param bool $isOnheapCacheEnabled
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setIsOnheapCacheEnabled(bool $isOnheapCacheEnabled): CacheConfiguration
+ {
+ $this->properties[self::PROP_IS_ONHEAP_CACHE_ENABLED] = $isOnheapCacheEnabled;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return bool|null
+ */
+ public function getIsOnheapCacheEnabled(): ?bool
+ {
+ return $this->getProperty(self::PROP_IS_ONHEAP_CACHE_ENABLED);
+ }
+
+ /**
+ *
+ *
+ * @param int $partitionLossPolicy one of @ref PartitionLossPolicy constants.
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ *
+ * @throws ClientException if error.
+ */
+ public function setPartitionLossPolicy(int $partitionLossPolicy): CacheConfiguration
+ {
+ ArgumentChecker::hasValueFrom(
+ $partitionLossPolicy,
+ 'partitionLossPolicy',
+ false,
+ [
+ self::PARTITION_LOSS_POLICY_READ_ONLY_SAFE,
+ self::PARTITION_LOSS_POLICY_READ_ONLY_ALL,
+ self::PARTITION_LOSS_POLICY_READ_WRITE_SAFE,
+ self::PARTITION_LOSS_POLICY_READ_WRITE_ALL,
+ self::PARTITION_LOSS_POLICY_IGNORE
+ ]);
+ $this->properties[self::PROP_PARTITION_LOSS_POLICY] = $partitionLossPolicy;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return int|null
+ */
+ public function getPartitionLossPolicy(): ?int
+ {
+ return $this->getProperty(self::PROP_PARTITION_LOSS_POLICY);
+ }
+
+ /**
+ *
+ *
+ * @param int $queryDetailMetricsSize
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setQueryDetailMetricsSize(int $queryDetailMetricsSize): CacheConfiguration
+ {
+ $this->properties[self::PROP_QUERY_DETAIL_METRICS_SIZE] = $queryDetailMetricsSize;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return int|null
+ */
+ public function getQueryDetailMetricsSize(): ?int
+ {
+ return $this->getProperty(self::PROP_QUERY_DETAIL_METRICS_SIZE);
+ }
+
+ /**
+ *
+ *
+ * @param int $queryParallelism
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setQueryParallelism(int $queryParallelism): CacheConfiguration
+ {
+ $this->properties[self::PROP_QUERY_PARALLELISM] = $queryParallelism;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return int|null
+ */
+ public function getQueryParallelism(): ?int
+ {
+ return $this->getProperty(self::PROP_QUERY_PARALLELISM);
+ }
+
+ /**
+ *
+ *
+ * @param bool $readFromBackup
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setReadFromBackup(bool $readFromBackup): CacheConfiguration
+ {
+ $this->properties[self::PROP_READ_FROM_BACKUP] = $readFromBackup;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return bool|null
+ */
+ public function getReadFromBackup(): ?bool
+ {
+ return $this->getProperty(self::PROP_READ_FROM_BACKUP);
+ }
+
+ /**
+ *
+ *
+ * @param int $rebalanceBatchSize
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setRebalanceBatchSize(int $rebalanceBatchSize): CacheConfiguration
+ {
+ $this->properties[self::PROP_REBALANCE_BATCH_SIZE] = $rebalanceBatchSize;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return int|null
+ */
+ public function getRebalanceBatchSize(): ?int
+ {
+ return $this->getProperty(self::PROP_REBALANCE_BATCH_SIZE);
+ }
+
+ /**
+ *
+ *
+ * @param float $rebalanceBatchesPrefetchCount
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setRebalanceBatchesPrefetchCount(float $rebalanceBatchesPrefetchCount): CacheConfiguration
+ {
+ $this->properties[self::PROP_REBALANCE_BATCHES_PREFETCH_COUNT] = $rebalanceBatchesPrefetchCount;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return float|null
+ */
+ public function getRebalanceBatchesPrefetchCount(): ?float
+ {
+ return $this->getProperty(self::PROP_REBALANCE_BATCHES_PREFETCH_COUNT);
+ }
+
+ /**
+ *
+ *
+ * @param float $rebalanceDelay
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setRebalanceDelay(float $rebalanceDelay): CacheConfiguration
+ {
+ $this->properties[self::PROP_REBALANCE_DELAY] = $rebalanceDelay;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return float|null
+ */
+ public function getRebalanceDelay(): ?float
+ {
+ return $this->getProperty(self::PROP_REBALANCE_DELAY);
+ }
+
+ /**
+ *
+ *
+ * @param int $rebalanceMode one of @ref RebalanceMode constants.
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ *
+ * @throws ClientException if error.
+ */
+ public function setRebalanceMode(int $rebalanceMode): CacheConfiguration
+ {
+ ArgumentChecker::hasValueFrom(
+ $rebalanceMode,
+ 'rebalanceMode',
+ false,
+ [self::REABALANCE_MODE_SYNC, self::REABALANCE_MODE_ASYNC, self::REABALANCE_MODE_NONE]);
+ $this->properties[self::PROP_REBALANCE_MODE] = $rebalanceMode;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return int|null
+ */
+ public function getRebalanceMode(): ?int
+ {
+ return $this->getProperty(self::PROP_REBALANCE_MODE);
+ }
+
+ /**
+ *
+ *
+ * @param int $rebalanceOrder
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setRebalanceOrder(int $rebalanceOrder): CacheConfiguration
+ {
+ $this->properties[self::PROP_REBALANCE_ORDER] = $rebalanceOrder;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return int|null
+ */
+ public function getRebalanceOrder(): ?int
+ {
+ return $this->getProperty(self::PROP_REBALANCE_ORDER);
+ }
+
+ /**
+ *
+ *
+ * @param float $rebalanceThrottle
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setRebalanceThrottle(float $rebalanceThrottle): CacheConfiguration
+ {
+ $this->properties[self::PROP_REBALANCE_THROTTLE] = $rebalanceThrottle;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return float|null
+ */
+ public function getRebalanceThrottle(): ?float
+ {
+ return $this->getProperty(self::PROP_REBALANCE_THROTTLE);
+ }
+
+ /**
+ *
+ *
+ * @param float $rebalanceTimeout
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setRebalanceTimeout(float $rebalanceTimeout): CacheConfiguration
+ {
+ $this->properties[self::PROP_REBALANCE_TIMEOUT] = $rebalanceTimeout;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return float|null
+ */
+ public function getRebalanceTimeout(): ?float
+ {
+ return $this->getProperty(self::PROP_REBALANCE_TIMEOUT);
+ }
+
+ /**
+ *
+ *
+ * @param bool $sqlEscapeAll
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setSqlEscapeAll(bool $sqlEscapeAll): CacheConfiguration
+ {
+ $this->properties[self::PROP_SQL_ESCAPE_ALL] = $sqlEscapeAll;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return bool|null
+ */
+ public function getSqlEscapeAll(): ?bool
+ {
+ return $this->getProperty(self::PROP_SQL_ESCAPE_ALL);
+ }
+
+ /**
+ *
+ *
+ * @param int $sqlIndexInlineMaxSize
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setSqlIndexInlineMaxSize(int $sqlIndexInlineMaxSize): CacheConfiguration
+ {
+ $this->properties[self::PROP_SQL_INDEX_INLINE_MAX_SIZE] = $sqlIndexInlineMaxSize;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return int|null
+ */
+ public function getSqlIndexInlineMaxSize(): ?int
+ {
+ return $this->getProperty(self::PROP_SQL_INDEX_INLINE_MAX_SIZE);
+ }
+
+ /**
+ *
+ *
+ * @param string|null $sqlSchema
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setSqlSchema(?string $sqlSchema): CacheConfiguration
+ {
+ $this->properties[self::PROP_SQL_SCHEMA] = $sqlSchema;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return string|null
+ */
+ public function getSqlSchema(): ?string
+ {
+ return $this->getProperty(self::PROP_SQL_SCHEMA);
+ }
+
+ /**
+ *
+ *
+ * @param int $writeSynchronizationMode one of @ref WriteSynchronizationMode constants.
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ *
+ * @throws ClientException if error.
+ */
+ public function setWriteSynchronizationMode(int $writeSynchronizationMode): CacheConfiguration
+ {
+ ArgumentChecker::hasValueFrom(
+ $writeSynchronizationMode,
+ 'writeSynchronizationMode',
+ false,
+ [self::WRITE_SYNC_MODE_FULL_SYNC, self::WRITE_SYNC_MODE_FULL_ASYNC, self::WRITE_SYNC_MODE_PRIMARY_SYNC]);
+ $this->properties[self::PROP_WRITE_SYNCHRONIZATION_MODE] = $writeSynchronizationMode;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return int|null
+ */
+ public function getWriteSynchronizationMode(): ?int
+ {
+ return $this->getProperty(self::PROP_WRITE_SYNCHRONIZATION_MODE);
+ }
+
+ /**
+ *
+ *
+ * @param CacheKeyConfiguration ...$keyConfigurations
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setKeyConfigurations(CacheKeyConfiguration ...$keyConfigurations): CacheConfiguration
+ {
+ $this->properties[self::PROP_CACHE_KEY_CONFIGURATION] = $keyConfigurations;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return CacheKeyConfiguration[]|null
+ */
+ public function getKeyConfigurations(): ?array
+ {
+ return $this->getProperty(self::PROP_CACHE_KEY_CONFIGURATION);
+ }
+
+ /**
+ *
+ *
+ * @param QueryEntity ...$queryEntities
+ *
+ * @return CacheConfiguration the same instance of the CacheConfiguration.
+ */
+ public function setQueryEntities(QueryEntity ...$queryEntities): CacheConfiguration
+ {
+ $this->properties[self::PROP_QUERY_ENTITY] = $queryEntities;
+ return $this;
+ }
+
+ /**
+ *
+ *
+ * @return QueryEntity[]|null
+ */
+ public function getQueryEntities(): ?array
+ {
+ return $this->getProperty(self::PROP_QUERY_ENTITY);
+ }
+
+ private function getProperty(int $prop)
+ {
+ if (array_key_exists($prop, $this->properties)) {
+ return $this->properties[$prop];
+ }
+ return null;
+ }
+
+ static function init(): void
+ {
+ self::$propInfo = array(
+ self::PROP_NAME => ObjectType::STRING,
+ self::PROP_CACHE_MODE => ObjectType::INTEGER,
+ self::PROP_ATOMICITY_MODE => ObjectType::INTEGER,
+ self::PROP_BACKUPS => ObjectType::INTEGER,
+ self::PROP_WRITE_SYNCHRONIZATION_MODE => ObjectType::INTEGER,
+ self::PROP_COPY_ON_READ => ObjectType::BOOLEAN,
+ self::PROP_READ_FROM_BACKUP => ObjectType::BOOLEAN,
+ self::PROP_DATA_REGION_NAME => ObjectType::STRING,
+ self::PROP_IS_ONHEAP_CACHE_ENABLED => ObjectType::BOOLEAN,
+ self::PROP_QUERY_ENTITY => new ObjectArrayType((new ComplexObjectType())->setPhpClassName(QueryEntity::class)),
+ self::PROP_QUERY_PARALLELISM => ObjectType::INTEGER,
+ self::PROP_QUERY_DETAIL_METRICS_SIZE => ObjectType::INTEGER,
+ self::PROP_SQL_SCHEMA => ObjectType::STRING,
+ self::PROP_SQL_INDEX_INLINE_MAX_SIZE => ObjectType::INTEGER,
+ self::PROP_SQL_ESCAPE_ALL => ObjectType::BOOLEAN,
+ self::PROP_MAX_QUERY_ITERATORS => ObjectType::INTEGER,
+ self::PROP_REBALANCE_MODE => ObjectType::INTEGER,
+ self::PROP_REBALANCE_DELAY => ObjectType::LONG,
+ self::PROP_REBALANCE_TIMEOUT => ObjectType::LONG,
+ self::PROP_REBALANCE_BATCH_SIZE => ObjectType::INTEGER,
+ self::PROP_REBALANCE_BATCHES_PREFETCH_COUNT => ObjectType::LONG,
+ self::PROP_REBALANCE_ORDER => ObjectType::INTEGER,
+ self::PROP_REBALANCE_THROTTLE => ObjectType::LONG,
+ self::PROP_GROUP_NAME => ObjectType::STRING,
+ self::PROP_CACHE_KEY_CONFIGURATION => new ObjectArrayType((new ComplexObjectType())->setPhpClassName(CacheKeyConfiguration::class)),
+ self::PROP_DEFAULT_LOCK_TIMEOUT => ObjectType::LONG,
+ self::PROP_MAX_CONCURRENT_ASYNC_OPS => ObjectType::INTEGER,
+ self::PROP_PARTITION_LOSS_POLICY => ObjectType::INTEGER,
+ self::PROP_EAGER_TTL => ObjectType::BOOLEAN,
+ self::PROP_STATISTICS_ENABLED => ObjectType::BOOLEAN
+ );
+ }
+
+ // This is not the public API method, is not intended for usage by an application.
+ public function write(BinaryCommunicator $communicator, MessageBuffer $buffer, string $name): void
+ {
+ $this->setName($name);
+
+ $startPos = $buffer->getPosition();
+ $buffer->setPosition($startPos +
+ BinaryUtils::getSize(ObjectType::INTEGER) +
+ BinaryUtils::getSize(ObjectType::SHORT));
+
+ foreach ($this->properties as $propertyCode => $property) {
+ $this->writeProperty($communicator, $buffer, $propertyCode, $property);
+ }
+
+ $length = $buffer->getPosition() - $startPos;
+ $buffer->setPosition($startPos);
+
+ $buffer->writeInteger($length);
+ $buffer->writeShort(count($this->properties));
+ }
+
+ private function writeProperty(BinaryCommunicator $communicator, MessageBuffer $buffer, int $propertyCode, $property): void
+ {
+ $buffer->writeShort($propertyCode);
+ $propertyType = self::$propInfo[$propertyCode];
+ switch (BinaryUtils::getTypeCode($propertyType)) {
+ case ObjectType::INTEGER:
+ case ObjectType::LONG:
+ case ObjectType::BOOLEAN:
+ $communicator->writeObject($buffer, $property, $propertyType, false);
+ return;
+ case ObjectType::STRING:
+ $communicator->writeObject($buffer, $property, $propertyType);
+ return;
+ case ObjectType::OBJECT_ARRAY:
+ $length = $property ? count($property) : 0;
+ $buffer->writeInteger($length);
+ foreach ($property as $prop) {
+ $prop->write($communicator, $buffer);
+ }
+ return;
+ default:
+ BinaryUtils::internalError();
+ }
+ }
+
+ // This is not the public API method, is not intended for usage by an application.
+ public function read(BinaryCommunicator $communicator, MessageBuffer $buffer): void
+ {
+ //length
+ $buffer->readInteger();
+ $this->readProperty($communicator, $buffer, self::PROP_ATOMICITY_MODE);
+ $this->readProperty($communicator, $buffer, self::PROP_BACKUPS);
+ $this->readProperty($communicator, $buffer, self::PROP_CACHE_MODE);
+ $this->readProperty($communicator, $buffer, self::PROP_COPY_ON_READ);
+ $this->readProperty($communicator, $buffer, self::PROP_DATA_REGION_NAME);
+ $this->readProperty($communicator, $buffer, self::PROP_EAGER_TTL);
+ $this->readProperty($communicator, $buffer, self::PROP_STATISTICS_ENABLED);
+ $this->readProperty($communicator, $buffer, self::PROP_GROUP_NAME);
+ $this->readProperty($communicator, $buffer, self::PROP_DEFAULT_LOCK_TIMEOUT);
+ $this->readProperty($communicator, $buffer, self::PROP_MAX_CONCURRENT_ASYNC_OPS);
+ $this->readProperty($communicator, $buffer, self::PROP_MAX_QUERY_ITERATORS);
+ $this->readProperty($communicator, $buffer, self::PROP_NAME);
+ $this->readProperty($communicator, $buffer, self::PROP_IS_ONHEAP_CACHE_ENABLED);
+ $this->readProperty($communicator, $buffer, self::PROP_PARTITION_LOSS_POLICY);
+ $this->readProperty($communicator, $buffer, self::PROP_QUERY_DETAIL_METRICS_SIZE);
+ $this->readProperty($communicator, $buffer, self::PROP_QUERY_PARALLELISM);
+ $this->readProperty($communicator, $buffer, self::PROP_READ_FROM_BACKUP);
+ $this->readProperty($communicator, $buffer, self::PROP_REBALANCE_BATCH_SIZE);
+ $this->readProperty($communicator, $buffer, self::PROP_REBALANCE_BATCHES_PREFETCH_COUNT);
+ $this->readProperty($communicator, $buffer, self::PROP_REBALANCE_DELAY);
+ $this->readProperty($communicator, $buffer, self::PROP_REBALANCE_MODE);
+ $this->readProperty($communicator, $buffer, self::PROP_REBALANCE_ORDER);
+ $this->readProperty($communicator, $buffer, self::PROP_REBALANCE_THROTTLE);
+ $this->readProperty($communicator, $buffer, self::PROP_REBALANCE_TIMEOUT);
+ $this->readProperty($communicator, $buffer, self::PROP_SQL_ESCAPE_ALL);
+ $this->readProperty($communicator, $buffer, self::PROP_SQL_INDEX_INLINE_MAX_SIZE);
+ $this->readProperty($communicator, $buffer, self::PROP_SQL_SCHEMA);
+ $this->readProperty($communicator, $buffer, self::PROP_WRITE_SYNCHRONIZATION_MODE);
+ $this->readProperty($communicator, $buffer, self::PROP_CACHE_KEY_CONFIGURATION);
+ $this->readProperty($communicator, $buffer, self::PROP_QUERY_ENTITY);
+ }
+
+ private function readProperty(BinaryCommunicator $communicator, MessageBuffer $buffer, int $propertyCode): void
+ {
+ $propertyType = self::$propInfo[$propertyCode];
+ switch (BinaryUtils::getTypeCode($propertyType)) {
+ case ObjectType::INTEGER:
+ case ObjectType::LONG:
+ case ObjectType::BOOLEAN:
+ $this->properties[$propertyCode] = $communicator->readTypedObject($buffer, $propertyType);
+ return;
+ case ObjectType::STRING:
+ $this->properties[$propertyCode] = $communicator->readObject($buffer, $propertyType);
+ return;
+ case ObjectType::OBJECT_ARRAY:
+ $length = $buffer->readInteger();
+ $properties = [];
+ for ($i = 0; $i < $length; $i++) {
+ $propClassName = $propertyType->getElementType()->getPhpClassName();
+ $property = new $propClassName();
+ $property->read($communicator, $buffer);
+ array_push($properties, $property);
+ }
+ $this->properties[$propertyCode] = $properties;
+ return;
+ default:
+ BinaryUtils::internalError();
+ }
+ }
+}
+
+CacheConfiguration::init();
http://git-wip-us.apache.org/repos/asf/ignite/blob/f28e4f3f/modules/platforms/php/src/Apache/Ignite/Cache/CacheEntry.php
----------------------------------------------------------------------
diff --git a/modules/platforms/php/src/Apache/Ignite/Cache/CacheEntry.php b/modules/platforms/php/src/Apache/Ignite/Cache/CacheEntry.php
new file mode 100644
index 0000000..bd933c6
--- /dev/null
+++ b/modules/platforms/php/src/Apache/Ignite/Cache/CacheEntry.php
@@ -0,0 +1,60 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Ignite\Cache;
+
+/**
+ * A cache entry (key-value pair).
+ */
+class CacheEntry
+{
+ private $key;
+ private $value;
+
+ /**
+ * Public constructor.
+ *
+ * @param mixed $key key corresponding to this entry.
+ * @param mixed $value value associated with the key.
+ */
+ public function __construct($key, $value)
+ {
+ $this->key = $key;
+ $this->value = $value;
+ }
+
+ /**
+ * Returns the key corresponding to this entry.
+ *
+ * @return mixed the key corresponding to this entry.
+ */
+ public function getKey()
+ {
+ return $this->key;
+ }
+
+ /**
+ * Returns the value corresponding to this entry.
+ *
+ * @return mixed the value corresponding to this entry.
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f28e4f3f/modules/platforms/php/src/Apache/Ignite/Cache/CacheInterface.php
----------------------------------------------------------------------
diff --git a/modules/platforms/php/src/Apache/Ignite/Cache/CacheInterface.php b/modules/platforms/php/src/Apache/Ignite/Cache/CacheInterface.php
new file mode 100644
index 0000000..a228073
--- /dev/null
+++ b/modules/platforms/php/src/Apache/Ignite/Cache/CacheInterface.php
@@ -0,0 +1,379 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Ignite\Cache;
+
+use Apache\Ignite\Type\ObjectType;
+use Apache\Ignite\Exception\ClientException;
+use Apache\Ignite\Query\Query;
+use Apache\Ignite\Query\CursorInterface;
+
+/**
+ * Interface representing and providing access to Ignite cache.
+ *
+ * An instance of the class with this interface should be obtained via the methods of Ignite Client.
+ * One instance of such a class provides access to one Ignite cache which is specified
+ * during the instance obtaining and cannot be changed after that.
+ *
+ * There are three groups of methods in the cache interface:
+ * - methods to configure the interface itself (optionally specify Ignite type for cache key and/or value)
+ * - methods to operate with the cache using Key-Value Queries
+ * - methods to operate with the cache using SQL and Scan Queries
+ *
+ */
+interface CacheInterface
+{
+ /** @name PeekMode
+ * @anchor PeekMode
+ * @{
+ */
+
+ /**
+ * Peek mode ALL
+ */
+ const PEEK_MODE_ALL = 0;
+
+ /**
+ * Peek mode NEAR
+ */
+ const PEEK_MODE_NEAR = 1;
+
+ /**
+ * Peek mode PRIMARY
+ */
+ const PEEK_MODE_PRIMARY = 2;
+
+ /**
+ * Peek mode BACKUP
+ */
+ const PEEK_MODE_BACKUP = 3;
+ /** @} */ // end of PeekMode
+
+ /* Methods to configure the cache interface */
+
+ /**
+ * Specifies a type of the cache key.
+ *
+ * Ignite client assumes that keys in all further operations with the cache
+ * will have the Ignite type specified by this method.
+ * Eg. the client will convert keys provided as input parameters of the Key-Value or SQL operations
+ * to the specified Ignite object type before sending the keys to a server.
+ *
+ * By default a type of the cache key is not specified (null).
+ *
+ * If the type is not specified then during operations Ignite client
+ * will do automatic mapping between some of the PHP types and Ignite object types -
+ * according to the mapping table defined in the description of the ObjectType class.
+ *
+ * @param int|ObjectType|null $type type of the keys in the cache:
+ * - either a type code of primitive (simple) type
+ * - or an instance of class representing non-primitive (composite) type
+ * - or null (means the type is not specified).
+ *
+ * @return CacheInterface the same instance of the class.
+ *
+ * @throws ClientException if error.
+ */
+ public function setKeyType($type): CacheInterface;
+
+ /**
+ * Specifies a type of the cache value.
+ *
+ * Ignite client assumes that values in all further operations with the cache
+ * will have the Ignite type specified by this method.
+ * Eg. the client will convert values provided as input parameters of the Key-Value or SQL operations
+ * to the specified Ignite object type before sending the values to a server.
+ *
+ * By default a type of the cache value is not specified (null).
+ *
+ * If the type is not specified then during operations Ignite client
+ * will do automatic mapping between some of the PHP types and Ignite object types -
+ * according to the mapping table defined in the description of the ObjectType class.
+ *
+ * @param int|ObjectType|null $type type of the values in the cache:
+ * - either a type code of primitive (simple) type (@ref PrimitiveTypeCodes)
+ * - or an instance of class representing non-primitive (composite) type
+ * - or null (means the type is not specified).
+ *
+ * @return CacheInterface the same instance of the class.
+ *
+ * @throws ClientException if error.
+ */
+ public function setValueType($type): CacheInterface;
+
+ /* Methods to operate with the cache using Key-Value Queries */
+
+ /**
+ * Retrieves a value associated with the specified key from the cache.
+ *
+ * @param mixed $key key.
+ *
+ * @return mixed value associated with the specified key, or null if it does not exist.
+ *
+ * @throws ClientException if error.
+ */
+ public function get($key);
+
+ /**
+ * Retrieves entries associated with the specified keys from the cache.
+ *
+ * @param array $keys keys.
+ *
+ * @return array the retrieved entries (key-value pairs) of CacheEntry.
+ * Entries with the keys which do not exist in the cache are not included into the array.
+ *
+ * @throws ClientException if error.
+ */
+ public function getAll(array $keys): array;
+
+ /**
+ * Associates the specified value with the specified key in the cache.
+ *
+ * Overwrites the previous value if the key exists in the cache,
+ * otherwise creates new entry (key-value pair).
+ *
+ * @param mixed $key key
+ * @param mixed $value value to be associated with the specified key.
+ *
+ * @throws ClientException if error.
+ */
+ public function put($key, $value): void;
+
+ /**
+ * Associates the specified values with the specified keys in the cache.
+ *
+ * Overwrites the previous value if a key exists in the cache,
+ * otherwise creates new entry (key-value pair).
+ *
+ * @param array $entries entries (key-value pairs) of CacheEntry to be put into the cache.
+ *
+ * @throws ClientException if error.
+ */
+ public function putAll(array $entries): void;
+
+ /**
+ * Checks if the specified key exists in the cache.
+ *
+ * @param mixed $key key to check.
+ *
+ * @return bool true if the key exists, false otherwise.
+ *
+ * @throws ClientException if error.
+ */
+ public function containsKey($key): bool;
+
+ /**
+ * Checks if all the specified keys exist in the cache.
+ *
+ * @param array $keys keys to check.
+ *
+ * @return bool true if all the keys exist,
+ * false if at least one of the keys does not exist in the cache.
+ *
+ * @throws ClientException if error.
+ */
+ public function containsKeys(array $keys): bool;
+
+ /**
+ * Associates the specified value with the specified key in the cache
+ * and returns the previous associated value, if any.
+ *
+ * Overwrites the previous value if the key exists in the cache,
+ * otherwise creates new entry (key-value pair).
+ *
+ * @param mixed $key key.
+ * @param mixed $value value to be associated with the specified key.
+ *
+ * @return mixed the previous value associated with the specified key, or null if it did not exist.
+ *
+ * @throws ClientException if error.
+ */
+ public function getAndPut($key, $value);
+
+ /**
+ * Associates the specified value with the specified key in the cache
+ * and returns the previous associated value, if the key exists in the cache.
+ * Otherwise does nothing and returns null.
+ *
+ * @param mixed $key key.
+ * @param mixed $value value to be associated with the specified key.
+ *
+ * @return mixed the previous value associated with the specified key, or null if it did not exist.
+ *
+ * @throws ClientException if error.
+ */
+ public function getAndReplace($key, $value);
+
+ /**
+ * Removes the cache entry with the specified key and returns the last associated value, if any.
+ *
+ * @param mixed $key key of the entry to be removed.
+ *
+ * @return mixed the last value associated with the specified key, or null if it did not exist.
+ *
+ * @throws ClientException if error.
+ */
+ public function getAndRemove($key);
+
+ /**
+ * Creates new entry (key-value pair) if the specified key does not exist in the cache.
+ * Otherwise does nothing.
+ *
+ * @param mixed $key key.
+ * @param mixed $value value to be associated with the specified key.
+ *
+ * @return true if the operation has been done, false otherwise.
+ *
+ * @throws ClientException if error.
+ */
+ public function putIfAbsent($key, $value): bool;
+
+ /**
+ * Creates new entry (key-value pair) if the specified key does not exist in the cache.
+ * Otherwise returns the current value associated with the existing key.
+ *
+ * @param mixed $key key.
+ * @param mixed $value value to be associated with the specified key.
+ *
+ * @return mixed the current value associated with the key if it already exists in the cache,
+ * null if the new entry is created.
+ *
+ * @throws ClientException if error.
+ */
+ public function getAndPutIfAbsent($key, $value);
+
+ /**
+ * Associates the specified value with the specified key, if the key exists in the cache.
+ * Otherwise does nothing.
+ *
+ * @param mixed $key key.
+ * @param mixed $value value to be associated with the specified key.
+ *
+ * @return bool true if the operation has been done, false otherwise.
+ *
+ * @throws ClientException if error.
+ */
+ public function replace($key, $value): bool;
+
+ /**
+ * Associates the new value with the specified key, if the key exists in the cache
+ * and the current value equals to the provided one.
+ * Otherwise does nothing.
+ *
+ * @param mixed $key key.
+ * @param mixed $value value to be compared with the current value associated with the specified key.
+ * @param mixed $newValue new value to be associated with the specified key.
+ *
+ * @return bool true if the operation has been done, false otherwise.
+ *
+ * @throws ClientException if error.
+ */
+ public function replaceIfEquals($key, $value, $newValue): bool;
+
+ /**
+ * Removes all entries from the cache, without notifying listeners and cache writers.
+ *
+ * @throws ClientException if error.
+ */
+ public function clear(): void;
+
+ /**
+ * Removes entry with the specified key from the cache, without notifying listeners and cache writers.
+ *
+ * @param mixed $key key to be removed.
+ *
+ * @throws ClientException if error.
+ */
+ public function clearKey($key): void;
+
+ /**
+ * Removes entries with the specified keys from the cache, without notifying listeners and cache writers.
+ *
+ * @param array $keys keys to be removed.
+ *
+ * @throws ClientException if error.
+ */
+ public function clearKeys($keys): void;
+
+ /**
+ * Removes entry with the specified key from the cache, notifying listeners and cache writers.
+ *
+ * @param mixed $key key to be removed.
+ *
+ * @return bool true if the operation has been done, false otherwise.
+ *
+ * @throws ClientException if error.
+ */
+ public function removeKey($key): bool;
+
+ /**
+ * Removes entry with the specified key from the cache, if the current value equals to the provided one.
+ * Notifies listeners and cache writers.
+ *
+ * @param mixed $key key to be removed.
+ * @param mixed $value value to be compared with the current value associated with the specified key.
+ *
+ * @return bool true if the operation has been done, false otherwise.
+ *
+ * @throws ClientException if error.
+ */
+ public function removeIfEquals($key, $value): bool;
+
+ /**
+ * Removes entries with the specified keys from the cache, notifying listeners and cache writers.
+ *
+ * @param array $keys keys to be removed.
+ *
+ * @throws ClientException if error.
+ */
+ public function removeKeys($keys): void;
+
+ /**
+ * Removes all entries from the cache, notifying listeners and cache writers.
+ *
+ * @throws ClientException if error.
+ */
+ public function removeAll(): void;
+
+ /**
+ * Returns the number of the entries in the cache.
+ *
+ * @param int ...$peekModes peek modes, values from @ref PeekMode constants.
+ *
+ * @return int the number of the entries in the cache.
+ *
+ * @throws ClientException if error.
+ */
+ public function getSize(int ...$peekModes): int;
+
+ /* Methods to operate with the cache using SQL and Scan Queries */
+
+ /**
+ * Starts an SQL, SQL Fields or Scan query operation.
+ *
+ * @param Query $query query to be executed.
+ *
+ * @return CursorInterface new instance of the class with interface representing a cursor
+ * to obtain the results of the query operation:
+ * - SqlFieldsCursorInterface in case of SqlFieldsQuery query
+ * - CursorInterface in case of other types of query
+ *
+ * @throws ClientException if error.
+ */
+ public function query(Query $query): CursorInterface;
+}