~fancycade/crystal-gdbm

gdbm bindings for Crystal
d2f91fd8 — fancycade 2 years ago
Add link to documentation
da685df0 — fancycade 2 years ago
Phrasing
ac6bf137 — fancycade 2 years ago
Add support link to README

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~fancycade/crystal-gdbm
read/write
git@git.sr.ht:~fancycade/crystal-gdbm

You can also use your local clone with git send-email.

#crystal-gdbm

GNU database management wrapper for Crystal.

Should work identically to the ruby version. Big thanks to the go version for implementation insights.

Detailed API documentation can be found here.

#Installation

  1. Add the dependency to your shard.yml:
dependencies:
  gdbm:
    git: https://git.sr.ht/~fancycade/crystal-gdbm
    branch: master
  1. Run shards install

#Usage

#Basic Usage

require "gdbm"

# Will make a new database by default (overwrite previous)
# db = GDBM.new("foobar.db")
# Set WR flag to open existing db or make new
db = GDBM.new("foobar.db", flags: GDBM::WR)

db.store "foo", "bar"

puts db.fetch "foo"

db.close

#Hash Methods

You can think of GDBM as a persistent hash map.

require "gdbm"

db = GDBM.new("foobar.db")

db["foo"] = "bar"

puts db["foo"] #=> "bar"

puts db["foo"]? #=> true

db["bar"] = "foo"

db.each do |k, v|
  puts k
  puts v
end

db.each_key do |k|
  puts k
end

db.each_value do |v|
  puts v
end

db.close

#Support

If you have questions or have an issue submit a ticket here.

#Contributors

#License

Fancy Cade hereby disclaims all copyright interest in crystal-gdbm written by fancycade.

fancycade 2019

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.