Coder Social home page Coder Social logo

skytable-php's Introduction

Skytable PHP Client

codecov

Skytable is an insanely fast, free and open-source, realtime NoSQL database that aims to provide flexible data modeling without compromising on performance or queryability โ€” at scale.

This library is a client for PHP that allows you to interact with the Skytable server. It is very simple to use.

Here an example to create a connection for Skytable:

<?php
$connection = new \Skytable\Connection('127.0.0.1', 2003);

Skytable Client with Connection

Client requires a Connection to be created. Client have methods to send command to the client.

<?php
$connection = new \Skytable\Connection('127.0.0.1', 2003);
$client = new \Skytable\Client($connection);

Running Basic Commands

After creating a connection, you can use the client to run basic commands.

<?php

$response = $client->heya();
$response = $client->whereami();

You can find the list of commands inside the Client class docblock.

Running Multiple Commands

To run multiple command, you need to use ActionBuilder. Every command have their own class. You need to initialize the command and add it to the ActionBuilder as payload.

<?php
$builder = new ActionsBuilder();
$builder->add((new \Skytable\Action\Sys\Metric\Storage()));
$builder->add((new \Skytable\Action\Sys\Metric\Health()));

$response = $client->execute($builder);

Initial commands after connection

While creating a connection, you can also specify a callback to run first commands after connected :

$connection = new Connection('127.0.0.1', 2003, static function($connection) {
    $payload = new ActionsBuilder();
    $payload->add(new \Skytable\Action\Create\Table('queue', 'keymap(str, list<str>)'));
    $payload->add(new \Skytable\Action\Select('default:queue'));
});

Managing a Queue

To be able to create a queue, you need to create a table with the keymap model.

<?php

$skytable->create_table('queue', 'keymap(str,list<str>)');
$skytable->select('default:queue');

$skytable->lmod_push('queue', '1');
$skytable->lmod_push('queue', '2');
$skytable->lmod_push('queue', '3');
$skytable->lmod_push('queue', '4');

var_dump($skytable->lmod_pop('queue'));
var_dump($skytable->lmod_rpop('queue'));
var_dump($skytable->lget('queue'));

skytable-php's People

Contributors

hkulekci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mkorkmaz

skytable-php's Issues

Use ConnectionFactory instead of creating socket inside the Connection class constructor

https://www.reddit.com/r/PHP/comments/107ehex/comment/j3r2ksv/

Newing socket factory in the Connection constructor only to create a socket client and throw the socket factory away hints that there should be a ConnectionFactory instead. It should accept socket factory in constructor. And offer a createConnection method that would call createClient on the socket factory and pass the returned socket client instance to constructor of Connection and then return the connection instance.

The callback parameter of Connection constructor is also weird. Why don't you just call the callback code after obtaining the new Connection instance?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.