Created
October 22, 2013 13:45
-
-
Save shinaisan/7101045 to your computer and use it in GitHub Desktop.
Moneta and KVS samples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8-unix -*- | |
require 'daybreak' | |
include Daybreak | |
def show_db | |
db = DB.new('tmp/daybreak') | |
puts "Hello " + db["Hello"] | |
puts "It " + db["It"] | |
puts "See " + db["See"] | |
ensure | |
db.close unless db.nil? | |
end | |
show_db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8-unix -*- | |
require 'daybreak' | |
include Daybreak | |
def make_db | |
db = DB.new('tmp/daybreak') | |
db.clear | |
db["Hello"] = "there" | |
db["It"] = "works" | |
db["See"] = "you" | |
ensure | |
db.close unless db.nil? | |
end | |
make_db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby; coding: utf-8-unix -*- | |
require 'kyotocabinet' | |
include KyotoCabinet | |
def show_db | |
db = DB.new | |
db.open('tmp/kc.kch', DB::OREADER) | |
puts "Hello " + db["Hello"] | |
puts "It " + db["It"] | |
puts "See " + db["See"] | |
ensure | |
db.close unless db.nil? | |
end | |
show_db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby; coding: utf-8-unix -*- | |
require 'kyotocabinet' | |
include KyotoCabinet | |
def make_db | |
db = DB.new | |
db.open('tmp/kc.kch', DB::OWRITER | DB::OCREATE) | |
db.clear | |
db["Hello"] = "there" | |
db["It"] = "works" | |
db["See"] = "you" | |
ensure | |
db.close unless db.nil? | |
end | |
make_db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8-unix -*- | |
require 'leveldb' | |
include LevelDB | |
def show_db | |
db = DB.new("tmp/leveldb") | |
puts "Hello " + db["Hello"] | |
puts "It " + db["It"] | |
puts "See " + db["See"] | |
ensure | |
db.close unless db.nil? | |
end | |
show_db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8-unix -*- | |
require 'leveldb' | |
include LevelDB | |
def make_db | |
db = DB.new("tmp/leveldb") | |
db.each{|k, v| db.delete(k)} | |
db["Hello"] = "there" | |
db["It"] = "works" | |
db["See"] = "you" | |
ensure | |
db.close unless db.nil? | |
end | |
make_db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby; coding: utf-8-unix -*- | |
require 'moneta' | |
STORE = { | |
PStore: {file: "tmp/pstore"}, | |
Daybreak: {file: "tmp/daybreak"}, | |
KyotoCabinet: {file: "tmp/kc.kch"}, | |
LevelDB: {dir: "tmp/leveldb"} | |
} | |
def show_db(store_type) | |
store = Moneta.new(store_type, STORE[store_type]) | |
puts "Hello " + store["Hello"] | |
puts "It " + store["It"] | |
puts "See " + store["See"] | |
ensure | |
store.close unless store.nil? | |
end | |
if ARGV[0].nil? | |
puts "Usage: ruby #{__FILE__} [#{STORE.keys.join('|')}]" | |
else | |
show_db ARGV[0].to_sym | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby; coding: utf-8-unix -*- | |
require 'moneta' | |
STORE = { | |
PStore: {file: "tmp/pstore"}, | |
Daybreak: {file: "tmp/daybreak"}, | |
KyotoCabinet: {file: "tmp/kc.kch"}, | |
LevelDB: {dir: "tmp/leveldb"} | |
} | |
def make_db(store_type) | |
store = Moneta.new(store_type, STORE[store_type]) | |
store.clear | |
store["Hello"] = "there" | |
store["It"] = "works" | |
store["See"] = "you" | |
ensure | |
store.close unless store.nil? | |
end | |
if ARGV[0].nil? | |
puts "Usage: ruby #{__FILE__} [#{STORE.keys.join('|')}]" | |
else | |
make_db ARGV[0].to_sym | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8-unix -*- | |
require 'pstore' | |
def show_db | |
db = PStore.new('tmp/pstore') | |
db.transaction do | |
puts "Hello " + db["Hello"] | |
puts "It " + db["It"] | |
puts "See " + db["See"] | |
end | |
end | |
show_db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby; coding: utf-8-unix -*- | |
require 'pstore' | |
def make_db | |
db = PStore.new('tmp/pstore') | |
db.transaction do | |
db["Hello"] = "there" | |
db["It"] = "works" | |
db["See"] = "you" | |
end | |
end | |
make_db |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment