GithubHelp home page GithubHelp logo

standardgalactic / foundationdb.jl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tanmaykm/foundationdb.jl

0.0 1.0 0.0 56 KB

FoundationDB client in Julia

License: Other

Julia 99.67% Shell 0.33%

foundationdb.jl's Introduction

FoundationDB Julia Client

Build Status Coverage Status codecov.io

The current implementation covers all of the C-APIs, and provides an easy to use Julia API layer over it for simple key-value pairs.

The Julia APIs are quite easy to follow, with this example:

using FoundationDB

open(FDBCluster()) do cluster                        # Read cluster configuration
    open(FDBDatabase(cluster)) do db                 # Open the database
        key = UInt8[0,1,2]                           # This is a key, and ...
        val = UInt8[9, 9, 9]                         # this is a value. Both are byte arrays.
        open(FDBTransaction(db)) do tran             # Start a transaction
            @test clearkey(tran, key) == nothing     # Delete a key if present
            @test getval(tran, key) == nothing       # Get value for a key (nothing if not present)
            @test setval(tran, key, val) == nothing  # Set value for a key
            @test getval(tran, key) == val           # We get the value, once it has been set
            @test commit(tran)                       # Commit changes we made in our snapshot
            @test_throws FDBError commit(tran)       # We can only commit once.
        end

        open(FDBTransaction(db)) do tran             # Open a new transaction 
            @test clearkey(tran, key) == nothing     # Delete a key
            @test getval(tran, key) == nothing
        end                                          # Transactions are auto-committed by default!
                                                     # And also retried automatically when possible

        open(FDBTransaction(db)) do tran             # Need a transaction even for read operation
            @test getval(tran, key) == nothing
        end                                          # Reads don't have to be committed
    end
end

Note: The Julia implementation makes use of Julia threading APIs. Make sure you have enabled threading and have at least two threads configured for Julia. E.g.:

$> JULIA_NUM_THREADS=2
$> export JULIA_NUM_THREADS
$> julia -e 'using Pkg; Pkg.test("FoundationDB")'

foundationdb.jl's People

Contributors

tanmaykm avatar

Watchers

 avatar

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.