• 2013-07-18

    SSDB now provides very detailed API doc

    Views: 4239 | No Comments

    The new detailed SSDB PHP Client API Documentation is now available. It is at this link: http://www.ideawu.com/ssdb/docs/php/.

    The document looks like this

    zsize
    
    Description
    
    Return the number of pairs of a zset.
    
    Parameters
    
        name - The name of the zset
    
    Return Value
    
    false on error, otherwise an integer of the zset, 0 if the zset does not exist.
    
    Example
    
    $ssdb->zsize('z');
    

    The document is also available in github repository.

    Posted by ideawu at 2013-07-18 21:25:03
  • 2013-07-17

    Iterate through zset in SSDB with PHP

    Views: 8652 | No Comments

    Connect to SSDB

    <?php
    require_once("SSDB.php");
    $ssdb = new SimpleSSDB('127.0.0.1', 8888);
    

    Generate test data

    $zname = 'test';
    for($i=0; $i<1000; $i++){
        $key = "k$i";
        $score = mt_rand(0, 100);
        $ssdb->zset($zname, $key, $score);
    }
    $size = $ssdb->zsize($zname);
    echo "total $size items\n";
    

    With this php codes, it will create a zset named zname, and insert 1000 items. Items may have same scores.

    Iterate

    $num = 1;
    $key_start = ''; 
    $score_start = ''; 
    while(1){
        $items = $ssdb->zscan($zname, $key_start, $score_start, '', 10);
        if(!$items){
            break;
        }   
        foreach($items as $key=>$score){
            printf("%5d: %-5s = %5d\n", $num, $key, $score);
            // remember the max key and its score
            $key_start = $key;
            $score_start = $score;
            $num += 1;
        }   
        echo "---\n";
    }
    

    Though we know there are 1000 items in the zset in this case, but for most chances there would be more items in one zset. So we cannot get all items at once.

    As demostration, we choose to get 10 items at a time, then get other 10 items after those. Repeat the same operation until we iterate through all items in the zset.

    Posted by ideawu at 2013-07-17 18:42:37 Tags:
  • 2013-07-11

    The C++ API for SSDB

    Views: 3812 | No Comments
    #include "link.h"
    
    Link *link = Link::connect(ip, port);
    const std::vector<Bytes> *resp = link->request("get", "a");
    if(resp == NULL){
        // error
    }else{
        // ok
    }
    
    Posted by ideawu at 2013-07-11 11:32:37
  • 2013-07-11

    Import existing LevelDB into SSDB

    Views: 8790 | 4 Comments

    Since 1.5.4, ssdb provides the leveldb-import tool to import a existing LevelDB into ssdb server. This tool is quite easy to use:

    Example:
        ./tools/leveldb-import 127.0.0.1 8888 ./leveldb/
    
    Usage:
        ./tools/leveldb-import ip port input_folder
    
    Options:
        ip - ssdb server ip address
        port - ssdb server port number
        input_folder - local leveldb folder
    
    Posted by ideawu at 11:26:36 Tags:
  • 2013-05-02

    SSDB multi masters replication is now beta

    Views: 6258 | 2 Comments

    SSDB released version 1.4.0. In this version, data replication mechanism is fully re-designed, that makes multi-masters replication mode move from experiment state to beta state.

    The changes are:

    • Replication re-designed, multi-masters replication mode is in beta state
    • info command return more info about every commands’ execution time and wait time
    • Upgrades to LevelDB 1.9.0

    SSDB multi-masters replication mode documentation: https://github.com/ideawu/ssdb/wiki/Replication#master-masterbeta

    Posted by ideawu at 2013-05-02 11:26:26 Tags:
|<<<1234>>>| 3/4 Pages, 18 Results.