0.0
No commit activity in last 3 years
No release in over 3 years
Simple local key-value store based on YAML::Store.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.7.13
~> 13.0
~> 3.0
 Project Readme

QuickStore

Gem Version Travis Build

Simple local key-value store based on YAML::Store.

Installation

Add this line to your application's Gemfile:

gem 'quick_store'

And then execute:

$ bundle

Or install it yourself as:

$ gem install quick_store

Usage

require 'quick_store'

Configuration

QuickStore.configure do |config|
  config.file_path = 'path/to/store/file.yml'
  config.key_separator = '|' # default is '/'
end

Storing, fetching, and deleting data

You can store, receive, and remove data from the store by using different methods:

# Using dynamic setters and getters
QuickStore.store.arbitrary_key = 'value'      # => "value"
QuickStore.store.arbitrary_key                # => "value"
QuickStore.store.delete_arbitrary_key         # => "value"

# Using the ::set, ::get, and ::delete methods
QuickStore.store.set(:arbitrary_key, 'value') # => "value"
QuickStore.store.get(:arbitrary_key)          # => "value"
QuickStore.store.delete(:arbitrary_key)       # => "value"

# Example for a nested key ('/' is the default key separator)
QuickStore.store.set('a/b/c', 'value')        # => {"b"=>{"c"=>"value"}}

QuickStore.store.get('a/b/c')                 # => "value"
QuickStore.store.get('a/b')                   # => {"c"=>"value"}
QuickStore.store.get('a')                     # => {"b"=>{"c"=>"value"}}

# Removing data for a certain nested key
QuickStore.store.delete('a/b/c')              # => {"b"=>{"c"=>nil}}
QuickStore.store.get('a')                     # => {"b"=>{"c"=>nil}}

# Removing data for all nested keys under a certain key
QuickStore.store.delete('a')                  # => {"b"=>{"c"=>nil}}
QuickStore.store.get('a')                     # => nil

Contributing

  1. Fork it ( https://github.com/[my-github-username]/quick_store/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

License

The quick_store gem is released under the MIT License.