class Nuummite

Overview

Nuummite is a minimalistic persistent key-value store.

Included Modules

Defined in:

nuummite.cr

Constant Summary

VERSION = 1

Constructors

Instance Method Summary

Constructor Detail

def self.new(folder : String, filename : String = "db.nuummite", sync : Bool = true) #

[View source]

Instance Method Detail

def [](key) #

Reads value to given key.


[View source]
def []=(key, value) #

Set key to value.


[View source]
def []?(key) #

Reads value to given key. Returns nil if key is not avilable.


[View source]
def auto_garbage_collect_after_writes : Int32 | Nil #

Number of writes or deletes before automatic garbage collection happens.

Set it to nil to disable automatic garbage collection.


[View source]
def auto_garbage_collect_after_writes=(auto_garbage_collect_after_writes : Int32 | Nil) #

Number of writes or deletes before automatic garbage collection happens.

Set it to nil to disable automatic garbage collection.


[View source]
def delete(key) #

Delets a key. Returns its value.


[View source]
def each(starts_with : String = "", &) #

Yields every key-value pair where the key starts with starts_with.

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

starts_with defaults to "". Then every key-value pair is yield.


[View source]
def garbage_collect #

Rewrites current state to logfile.


[View source]
def shutdown #

Shuts down this instance of Nuummite.


[View source]
def sync : Bool #

If true the logfile is flushed on every write.


[View source]
def sync=(sync : Bool) #

If true the logfile is flushed on every write.


[View source]