{"id":13483076,"url":"https://github.com/crystal-community/leveldb","last_synced_at":"2025-07-27T14:31:08.976Z","repository":{"id":90863180,"uuid":"62962411","full_name":"crystal-community/leveldb","owner":"crystal-community","description":"Crystal binding for LevelDB","archived":false,"fork":false,"pushed_at":"2020-03-06T18:09:49.000Z","size":57,"stargazers_count":39,"open_issues_count":1,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-30T16:41:34.595Z","etag":null,"topics":["crystal","leveldb"],"latest_commit_sha":null,"homepage":null,"language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crystal-community.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-07-09T18:04:25.000Z","updated_at":"2024-07-19T06:31:14.000Z","dependencies_parsed_at":"2024-01-27T09:09:50.899Z","dependency_job_id":"0cf2a2dc-281e-4e88-957b-19b288216ea4","html_url":"https://github.com/crystal-community/leveldb","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crystal-community%2Fleveldb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crystal-community%2Fleveldb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crystal-community%2Fleveldb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crystal-community%2Fleveldb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crystal-community","download_url":"https://codeload.github.com/crystal-community/leveldb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227810270,"owners_count":17823176,"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":["crystal","leveldb"],"created_at":"2024-07-31T17:01:08.052Z","updated_at":"2024-12-02T22:15:22.141Z","avatar_url":"https://github.com/crystal-community.png","language":"Crystal","funding_links":[],"categories":["Database Drivers/Clients"],"sub_categories":[],"readme":"# LevelDB \u003cimg src=\"https://raw.githubusercontent.com/crystal-community/leveldb/master/images/crystal-leveldb-logo2.png\" alt=\"crystal levedb\" width=\"48\"\u003e\n\nCrystal binding for [LevelDB](https://github.com/google/leveldb).\n\n[![Build Status](https://travis-ci.org/crystal-community/leveldb.svg?branch=master)](https://travis-ci.org/crystal-community/leveldb)\n\n\u003e LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.\n\n## Installation\n\n### Prerequisites\n\nDebian:\n```\nsudo apt-get install libleveldb-dev libleveldb1v5 libsnappy1v5\n```\n\n### shard.yml\n\n```yaml\ndependencies:\n  leveldb:\n    github: \"crystal-community/leveldb\"\n    version: \"~\u003e 0.2.0\"\n```\n\n## Usage\n\n### Basic usage\n\n```crystal\nrequire \"leveldb\"\n\n# Create DB (if does not exist yet) and open\ndb = LevelDB::DB.new(\"./db\")\n\n# Put, get, delete\ndb.put(\"name\", \"Sergey\")\ndb.get(\"name\")  # =\u003e \"Sergey\"\ndb.delete(\"name\")\ndb.get(\"name\")  # =\u003e nil\n\n# [], []= methods work the same\ndb[\"city\"] = \"Berlin\"\ndb[\"city\"]  # =\u003e \"Berlin\"\n\n# Iterate through all the keys\ndb.each do |key, val|\n  puts \"#{key} = #{val}\"\nend\n\n# Close database\ndb.close\ndb.closed? # =\u003e true\ndb.opened? # =\u003e false\n\n# Close the database and remove all the data\ndb.destroy\n\n# Remove all the keys, keep the database open\ndb.clear\n```\n\n### Batches \n\u003e Apply a atomic batch of of operation to the key-value store.\n\n```crystal\nrequire \"leveldb\"\n\ndb = LevelDB::DB.new(\"./db\")\nbegin\n  batch = LevelDB::Batch.new\n\n  batch.put(\"name\",\"Martin\")\n  batch.put(\"age\",\"25\")\n  batch.put(\"location\",\"Bariloche\")\n  batch.delete(\"age\")\n\n  # write batch to the db in atomic way\n  db.write(batch)\n\n  puts db.get(\"name\")\n  puts db.get(\"age\") # nil\n  puts db.get(\"location\")\nensure\n  # free memory \n  batch.destroy \n  # close the database\n  db.close\nend\n\n\n```\n\n### Snapshots\n\n\u003e Snapshots provide consistent read-only views over the entire state of the key-value store.\n\n```crystal\ndb = LevelDB::DB.new(\"./db\")\n\ndb.put(\"a\", \"1\")\ndb.get(\"a\")  # =\u003e \"1\"\n\nsnapshot = db.create_snapshot\ndb.delete(\"a\")\ndb.get(\"a\")  # =\u003e nil\n\ndb.set_snapshot(snapshot)\ndb.get(\"a\")  # =\u003e \"1\"\n\ndb.unset_snapshot\ndb.get(\"a\")  # =\u003e nil\n```\n\n\n## Performance\n\nThere is performance comparison of LevelDB and other stores from\n[Kiwi](https://github.com/greyblake/crystal-kiwi#performance-porn) project.\n\n![LevelDB VS other storages](https://sc-cdn.scaleengine.net/i/8a5361ab85b005f7bfb6ed7941b4a5ef.jpg)\n\n## Contributors\n\n- [greyblake](https://github.com/greyblake) Sergey Potapov - creator, maintainer\n- [twisterghost](https://github.com/twisterghost) Michael Barrett\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrystal-community%2Fleveldb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrystal-community%2Fleveldb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrystal-community%2Fleveldb/lists"}