{"id":13508830,"url":"https://github.com/JonGretar/ExBitcask","last_synced_at":"2025-03-30T11:32:51.670Z","repository":{"id":28653503,"uuid":"32172877","full_name":"JonGretar/ExBitcask","owner":"JonGretar","description":"Elixir wrapper of Basho's Bitcask Key/Value store.","archived":false,"fork":false,"pushed_at":"2015-03-14T12:18:14.000Z","size":224,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-28T09:29:13.978Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JonGretar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-13T18:16:58.000Z","updated_at":"2023-10-17T09:01:25.000Z","dependencies_parsed_at":"2022-09-04T17:22:02.495Z","dependency_job_id":null,"html_url":"https://github.com/JonGretar/ExBitcask","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonGretar%2FExBitcask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonGretar%2FExBitcask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonGretar%2FExBitcask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonGretar%2FExBitcask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JonGretar","download_url":"https://codeload.github.com/JonGretar/ExBitcask/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246314012,"owners_count":20757454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:00:59.128Z","updated_at":"2025-03-30T11:32:51.233Z","avatar_url":"https://github.com/JonGretar.png","language":"Erlang","funding_links":[],"categories":["ORM and Datamapping"],"sub_categories":[],"readme":"# ExBitcask [![Build Status](https://secure.travis-ci.org/JonGretar/ExBitcask.png?branch=master)](http://travis-ci.org/JonGretar/ExBitcask)\n\nElixir wrapper of [Basho's Bitcask](https://github.com/basho/bitcask). Bitcask is a Log-Structured Hash Table for Fast\nKey/Value Data.\n\n## Notes on Bitcask\n\nInstead of the usual method of requiring the wrapped library as a dependency I have chosen to include the Bitcask source\ncode in the library. This will vastly simplify getting and compiling the library. On the minus side it will mean that\nupdating to a new release of Bitcask will take a few days. But I'll try to be quick about it.\n\nExBitcask currently users version **2.0.0** of bitcask.\n\n## Setup\n\nFirst, add ExBitcask to your mix.exs dependencies:\n\n```elixir\ndef deps do\n  [{:ex_bitcask, \"~\u003e VERSION\"}]\nend\n```\n\nand run $ `mix deps.get`. Now, list the :ex_bitcask application as your application dependency:\n\n```elixir\ndef application do\n  [applications: [:ex_bitcask]]\nend\n```\n\n## Usage\n\nFor full API docs please view the projects [Hexdocs](http://hexdocs.pm/ex_bitcask).\n\n```elixir\ndb = ExBitcask.open(\"my.db\", [:read_write])\nExBitcask.put(db, \"Foo\", \"bar\")\nExBitcask.put(db, \"Hello\", \"world\")\nExBitcask.get(db, \"Hello\")\n# {:ok, \"world\"}\n```\n\n### Streams\n\nLazy Streams can be generated for both the keys and the {key, val} of the database.\n\n```elixir\nExBitcask.stream_keys(db) |\u003e Stream.map(\u0026(String.upcase(\u00261))) |\u003e Enum.to_list\n# [\"FOO\", \"HELLO\"]\nExBitcask.stream_keyvals(db) |\u003e Enum.to_list\n# [{\"Foo\", \"bar\"}, {\"Hello\", \"world\"}]\n```\n\n### Serialization\n\nIf a value is in binary or String format it will be put in as is.\nOther terms will be serialized into binary using `:erlang.term_to_binary/1` with a prefix so ExBitcask knows when to de-serialize a value.\n\nThis means a value can be any complex Elixir object. Like the database connection itself.\n\n```elixir\nExBitcask.put(db, \"myown_db\", db)\ndb_from_db = ExBitcask.get!(db, \"myown_db\")\nExBitcask.get(db_from_db, \"Hello\")\n# {:ok, \"world\"}\n```\n\n## What is Bitcask\n\n(*[From Wikipedia](https://en.wikipedia.org/wiki/Bitcask)*)\n\nBitcask is an Erlang application that provides an API for storing and retrieving key/value data into a log-structured\nhash table that provides very fast access. The design owes a lot to the principles found in log-structured file systems\nand draws inspiration from a number of designs that involve log file merging.\n\n### Strengths\n\n#### Low latency per item read or written\nThis is due to the write-once, append-only nature of the Bitcask database files. High throughput, especially when\nwriting an incoming stream of random items Because the data being written doesn't need to be ordered on disk and\nbecause the log structured design allows for minimal disk head movement during writes these operations generally\nsaturate the I/O and disk bandwidth.\n\n#### Ability to handle datasets larger than RAM w/o degradation\nBecause access to data in Bitcask is direct lookup from an in-memory hash table finding data on disk is very\nefficient, even when data sets are very large.\n\n#### Single Seek to Retrieve Any Value\nBitcask's in-memory hash-table of keys point directly to locations on disk where the data lives. Bitcask never uses\nmore than one disk seek to read a value and sometimes, due to file-system caching done by the operating system, even\nthat isn't necessary.\n\n#### Predictable Lookup and Insert Performance\nAs you might expect from the description above, read operations have a fixed, predictable behavior. What you might not\nexpect is that this is also true for writes. Write operations are at most a seek to the end of the current file open\nwriting and an append to that file.\n\n#### Fast, bounded Crash Recovery\nDue to the append-only write once nature of Bitcask files, recovery is easy and fast. The only items that might be\nlost are partially written records at the tail of the file last opened for writes. Recovery need only review the last\nrecord or two written and verify CRC data to ensure that the data is consistent.\n\n#### Easy Backup\nIn most systems backup can be very complicated but here again Bitcask simplifies this process due to its append-only\nwrite once disk format. Any utility that archives or copies files in disk-block order will properly backup or copy a\nBitcask database.\n\n### Weakness\n\n#### Keys Must Fit In Memory\nBitcask keeps all keys in memory at all times, this means that your system must have enough memory to contain your\nentire keyspace with room for other operational components and operating system resident filesystem buffer space.\n\n## Licence\n\nLicenced under the Apache License 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJonGretar%2FExBitcask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJonGretar%2FExBitcask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJonGretar%2FExBitcask/lists"}