Giter Site home page Giter Site logo

aioconfig.py's Introduction

aioconfig

aioconfig efficiently and thread-safely stores configurations in the background (asynchronously).

Installation

pip install aioconfig

Usage

The interface of aioconfig is dramatically easy to use. For example, both set(key, value) and await set(key, value) store a pair of key/value, which the former one is a fire-and-forget asynchronous function call while the latter one blocks until the data written onto the disk.

Init

import aioconfig
storage = aioconfig.get_storage(await aioconfig.attach('example.db'))
section = await aioconfig.get('default')

Delete

section.delete(key='foo')

Blocking delete (wait until it's done)

await section.delete(key='foo')

Get

value1 = await section.get(key='foo', default='bar')
value2 = await section.get(key='baz', default=12.3)

Get all

value = await section.get_all()

Set (fire-and-forget)

section.set(key='foo', value='bar')
section.set(key='baz', value=12.3)

Blocking set (wait until it's done)

await section.set(key='foo', value='bar')
await section.set(key='baz', value=12.3)

Batch set (fire-and-forget) (TBD)

with storage.transation():
    storage.set(
        key='foo', value='bar',
        section='default_section')
    storage.set(
        key='baz', value=12.3,
        section='default_section')

Blocking batch set (wait until it's done) (TBD)

async with storage.transation():
    storage.set(
        key='foo', value='bar',
        section='default_section')
    storage.set(
        key='baz', value=12.3,
        section='default_section')

aioconfig.py's People

Contributors

mrjohannchang avatar

Stargazers

 avatar

Watchers

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