PHP code example of s00d / rocksdb-client-php

1. Go to this page and download the library: Download s00d/rocksdb-client-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

s00d / rocksdb-client-php example snippets


   'providers' => [
       // Other Service Providers

       s00d\RocksDB\RocksDBServiceProvider::class,
   ],
   

   'aliases' => [
       // Other Facades

       'RocksDB' => s00d\RocksDB\Facades\RocksDB::class,
   ],
   

   use RocksDB;

   // Put a value
   RocksDB::put('key', 'value');

   // Get a value
   $value = RocksDB::get('key');

   // Delete a key
   RocksDB::delete('key');

   // Other available methods...
   

   use s00d\RocksDB\RocksDBClient;

   $client = new RocksDBClient('127.0.0.1', 12345);

   // If you have a token
   // $client = new RocksDBClient('127.0.0.1', 12345, 'your-token');
   

   // Put a value
   $client->put('key', 'value');

   // Get a value
   $value = $client->get('key');

   // Delete a key
   $client->delete('key');

   // Other available methods...
   

RocksDB::put('key', 'value', 'optional_column_family');

$value = RocksDB::get('key', 'optional_column_family', 'default_value');

RocksDB::delete('key', 'optional_column_family');

RocksDB::merge('key', 'value', 'optional_column_family');

$columnFamilies = RocksDB::listColumnFamilies('path_to_db');

RocksDB::createColumnFamily('new_column_family');

RocksDB::dropColumnFamily('column_family');

RocksDB::compactRange('start_key', 'end_key', 'optional_column_family');

$txnId = RocksDB::beginTransaction();

RocksDB::commitTransaction($txnId);

RocksDB::rollbackTransaction($txnId);
bash
composer 
bash
   php artisan vendor:publish --provider="s00d\RocksDB\RocksDBServiceProvider"