GithubHelp home page GithubHelp logo

plumpmath / spicerack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jackrusher/spicerack

0.0 0.0 0.0 17 KB

A Clojure wrapper for MapDB, which is a fast, disk-persistent data-structures library.

License: Eclipse Public License 1.0

Clojure 100.00%

spicerack's Introduction

The spicerack logo

Sometimes, while making tasty computer programs, one needs a place to store labeled containers of data. Spicerack is that kind of place.

This is a Clojure wrapper for MapDB โ€” a fast, disk-persistent data-structures library. Like many wrappers around Java libraries, this one is woefully incomplete. MapDB supports several data structures (Map, Set and List, implemented with trees and hashes), and can do fun things with them, like creating a hash table that acts as a cache with automatic eviction and change listeners. This wrapper doesn't support any of that. It just provides an idiomatic way to store something like a Clojure hash-map on disk.

I plan to add the other data types over time, as I need them for my own projects. In the meantime, these bits are well-tested and already very useful.

Usage

[spicerack "0.1.3"]

There are only a handful of functions in this wrapper. It provides open-database and close (though it's best to use clojure's with-open macro to handle closing), put!, remove!, and update!. Getting is done with clojure.core's get function.

(require '[spicerack.core :refer [open-database open-hashmap put! update!]])

(with-open [db (open-database "./baking-db")]
  (let [ingredients (open-hashmap db "ingredient-hashmap")]
    (put! ingredients :apple-pie [:flour :butter :sugar :apples])
    ;;=> [:flour :butter :sugar :apples]
    (update! ingredients :apple-pie conj :cinnamon)))
    ;;=> [:flour :butter :sugar :apples :cinnamon]

See the tests for more examples!

License

Copyright ยฉ 2016-2017 Jack Rusher

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

spicerack's People

Contributors

jackrusher avatar plexus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.