Code Monkey home page Code Monkey logo

nuummite's Introduction

Nuummite Build Status

Nuummite is a tiny persistent embedded key-value store. All data is kept in RAM (in a Crystal Hash) and is also written to disk. So don't use Nuummite to handle big chunks of data. Keys and Values are always Strings. It just comes with the most basic operations.

Installation

Add this to your application's shard.yml:

dependencies:
  nuummite:
    github: codesteak/nuummite
    version: ~> 0.1.5

Usage

require "nuummite"

Open the database

db = Nuummite.new("path/to/folder", "optional-filename.db")

# You can also have multiple:
flowers  = Nuummite.new("flowers")
minerals = Nuummite.new("minerals")

Put some values in

db["hello"] = "world"
db["42"] = "Answer to the Ultimate Question of Life, The Universe, and Everything"
db["whitespace"] = "Hey\n\t\t :D"

Read values

db["hello"]? # => "world"
db["ehhhh"]? # => nil

#Note: db is locked while reading, so don't write to db!
db.each do |key,value|
  # reads everything
end

db["crystals/ruby"] = "9.0"
db["crystals/quartz"] = "~ 7.0"
db["crystals/nuummite"] = "5.5 - 6.0"

db.each("crystals/") do |key,value|
  # only crystals in here
end

Delete

db.delete "hello"

Garbage collect

Since values are saved to disk in a log style, file sizes grow, your key-value store needs to rewrite all data at some point:

db.garbage_collect

By default it auto garbage collects after 10_000_000 writes. To modify this behavior you can:

# garbage collects after 1000 writes or deletes
db.auto_garbage_collect_after_writes = 1000

# does not auto garbage collect
db.auto_garbage_collect_after_writes = nil  

Shutdown

You can also shutdown Nuummite by

db.shutdown

That's all you need to know ๐Ÿ˜„

Contributing

  1. Fork it ( https://github.com/codesteak/nuummite/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

nuummite's People

Contributors

codesteak avatar hannesbraun avatar lecafard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

shabesoglu

nuummite's Issues

Error resolving nuummite (~> 0.1)

I'll preface this with the fact that I'm very new to Crystal, bu when I update my shard.yml with:

dependencies:
  nuummite:
    github: codesteak/nuummite
    version: ~> 0.1.0

... I get Error resolving nuummite (~> 0.1)

Any idea if this is a shards-specific issue? Or does this have something to do with the Nuummite shard.yml?

Allow set data to expire

We could build a Rails-like persistent value cache if we could set a value with an expiration date (seconds). For example, I want to cache a JSON API response for 15mins when a iteratively run specs.

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.