No commit activity in last 3 years
No release in over 3 years
Stack, Queue and SortedList structures implemented in Couchbase
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.2.0.z.beta3
 Project Readme

CouchbaseStructures

Simple data structures to create persisted data structures: Queue, Stack and Sorted List. At this time SortedList is just single values: strings, integers, floats, etc. I will make a more sophisticated SortedList soon. These patterns do not require Couchbase 2.0, they are Key-Value based patterns and work fine in Couchbase Server 1.8.x as well.

Dependencies

I will only work on backwards compatibility in these gems if there is real demand to do so, otherwise I assume the latest edge gem of gem couchbase which is designed for Couchbase Server 2.0 with all it's optimizations and speed!

gem 'couchbase-settings' (http://github.com/scalabl3/couchbase-settings)

gem 'couchbase-docstore' (http://github.com/scalabl3/couchbase-docstore)

Installation

Add these lines to your application's Gemfile:

gem 'couchbase-settings'
gem 'map'
gem 'couchbase-docstore'
gem 'couchbase-structures'

And then execute:

$ bundle

Or install it yourself as:

$ gem install couchbase-settings couchbase-docstore couchbase-structures

Usage

Assuming you have setup Couchbase Server, the libcouchbase C native extensions library that the couchbase gem requires, and installed the Couchbase gem.

Queue

require 'couchbase_structures'

queue = CouchbaseStructures::Queue.new("myqueue")
queue.enqueue({ :item1 => "my item"})
queue.enqueue({ :item2 => "my other item"})

next = queue.pop()
# => { :item1 => "my item "}

next = queue.pop()
# => { :item2 => "my other item "}

Stack

require 'couchbase_structures'

stack = CouchbaseStructures::Stack.new("mystack")
stack.push({ :item1 => "my item"})
stack.push({ :item2 => "my other item"})

next = stack.pop()
# => { :item2 => "my other item "}

next = stack.pop()
# => { :item1 => "my item "}

SortedList

require 'couchbase_structures'

sorted = CouchbaseStructures::SortedList.new("sortedlist")
sorted.add("abcdef"})
sorted.add("aabcde")

sorted.items
# => ["aabcde", "abcdef"]

Coming Soon

  • Add some safeguarding code for mega-concurrency
  • Add more complex usage for SortedList, store complex classes instead of just simple values

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

© 2012, Jasdeep Jaitla, aka @scalabl3, MIT License