• 2013-12-19

    SSDB 1.6.7 supports key expiration(TTL)

    Views: 14181 | 6 Comments

    Since SSDB 1.6.7, the key expiration(TTL) feature is supported. You can set a value to a key, with a time to live. After this time, the will be automatically deleted. With this feature, you can use SSDB as a persistent cache service.

    Usage:

    $ssdb->setx('key', 'value', 60);
    

    The code above set key=value, and key will be expired after 60 seconds.

    Download SSDB NoSQL database: https://github.com/ideawu/ssdb

    Posted by ideawu at 2013-12-19 13:46:06 Tags: , ,
  • 2013-10-17

    SSDB C++ client API supported

    Views: 11800 | 2 Comments

    I am pleased to announce, the SSDB C++ client API is now provided! Along with documentations!

    The API is very easy to use, compiling a program is as simple as

    g++ -o hello-ssdb libssdb.a hello-ssdb.cpp
    

    Where hello-ssdb.cpp is a SSDB client application.

    SSDB C++ API Doc: http://www.ideawu.com/ssdb/docs/cpp/

    Posted by ideawu at 2013-10-17 22:32:58 Tags: ,
  • 2013-10-08

    SSDB now supports Snappy compression

    Views: 13348 | 2 Comments

    Since version 1.6.2, SSDB integrates with the Snappy compression library.

    Snappy is a fast compression library developed by Google, and is widely used inside Google, also many famous open source software, like Cassandra, Hadoop, etc.

    Althought LevelDB will auto check you system to see if there is Snappy installed in its Makefile, and enable Snappy if it find Snappy installed, but the compilation usually failed dure to various dependency problem. To make this problem never happen, SSDB integrates with Snappy in the source code level, that is the Snappy source code is provided in SSDB’s source code package.

    So SSDB’s compilation and installation is as the same as previous versions. And most important, the new version SSDB with Snappy is completely compatible with older version of SSDB without Snappy.

    You can still not enable Snappy in your ssdb.conf file anyway. If you use the ssdb.conf file without Snappy compression option shown below, the default option is no-compression. You can enable Snappy compression by this option in ssdb.conf:

    leveldb:
    	compression: yes
    

    SSDB A fast NoSQL database server with zset data type, suitable for storing very large list of data: https://github.com/ideawu/ssdb

    Posted by ideawu at 2013-10-08 21:48:17 Tags: ,
  • 2013-07-17

    Iterate through zset in SSDB with PHP

    Views: 6737 | 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

    Import existing LevelDB into SSDB

    Views: 6882 | 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 2013-07-11 11:26:36 Tags:
|<<<123>>>| 1/3 Pages, 14 Results.