GithubHelp home page GithubHelp logo

key_db's Introduction

Layer-Db

Layer Db is a lightweight and blazingly fast embedded key-value database. It is designed to be an in-memory but persisted database that uses append-only logging for persistence in a separate thread, to reduce performance hits due to persistence.

I created Layer Db to provide a simple and efficient way to store and retrieve data in a key-value format, without the need for a separate database server or external dependencies. It is written in Rust for speed and safety, and is easy to install and use.

With Layer Db, you can quickly and easily store and retrieve data using simple key-value pairs, and access the data from any application or process that has access to the database file. It is ideal for applications that require fast and efficient access to data, without the overhead of a full-featured database server.

I hope that you will find Layer Db to be a valuable tool in your development efforts, and I welcome any feedback or suggestions for improvements.

Written in Rust for speed and safety :) .

Installation

To install Layer Db, use pip:

pip install layer-db

Develop Locally

create a virtual env :

python -m venv .env 
source .env/bin/activate

install maturin (Build Tool) :

pip install maturin 

install dependencies

pip install -r requirements.txt

Develop and install wheels locally (intalled in the venv) :

maturin develop 

should be run everytime code changes .

Usage

To use Layer Db, import the layer_db module and call the load() function to load a database file:

import layer_db

db = layer_db.load("test.db")

This will load an existing database file called test.db, or create a new, empty database if the file does not exist.

Once the database is loaded, you can use the set() method to store key-value pairs in the database:

db.set("hello", "world")

This will store the value "world" in the database, associated with the key "hello". The set() method returns True if the operation is successful, or raises an exception if there is an error.

To retrieve a value from the database, use the get() method, passing in the key for the value you want to retrieve:

value = db.get("hello")

This will return the value associated with the key "hello", or None if the key does not exist in the database.

To remove a key-value pair from the database, use the remove() method, passing in the key for the pair you want to remove:

value = db.remove("hello")

This will remove the key-value pair associated with the key "hello" from the database, and return the value that was removed.

When you are finished using the database, call the close() method to close the database and shut down any background threads:

db.close()

This will ensure that all data is properly persisted to disk and that all background threads are terminated.

Todo

Make Layer Db compatible with the Redis API Add an option to disable persistence, for use in situations where data can be safely discarded after the application exits.

key_db's People

Contributors

aabidsofi19 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.