All Projects → kwebio → shoebox

kwebio / shoebox

Licence: LGPL-3.0 license
ShoeBox is a Kotlin library for persistent data storage that supports views and the observer pattern. While often used with Kweb, it doesn't need to be.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to shoebox

moosefs-csi
Container Storage Interface (CSI) for MooseFS
Stars: ✭ 44 (-8.33%)
Mutual labels:  storage, persistent-storage
Openebs
Leading Open Source Container Attached Storage, built using Cloud Native Architecture, simplifies running Stateful Applications on Kubernetes.
Stars: ✭ 7,277 (+15060.42%)
Mutual labels:  storage, persistent-storage
haro
Haro is a modern immutable DataStore
Stars: ✭ 24 (-50%)
Mutual labels:  storage
MIT6.824-2021
4 labs + 2 challenges + 4 docs
Stars: ✭ 594 (+1137.5%)
Mutual labels:  storage
gcsfs
Google Cloud Storage filesystem for PyFilesystem2
Stars: ✭ 36 (-25%)
Mutual labels:  storage
oras
ORAS CLI
Stars: ✭ 672 (+1300%)
Mutual labels:  storage
react-native-modest-cache
💾 Simple cache for AsyncStorage
Stars: ✭ 23 (-52.08%)
Mutual labels:  storage
xd-storage-helper
A little helper to make storing key-value-pairs (e.g. settings) for Adobe XD plugins easier.
Stars: ✭ 22 (-54.17%)
Mutual labels:  storage
ECS-CommunityEdition
ECS Community Edition "Free & Frictionless"
Stars: ✭ 125 (+160.42%)
Mutual labels:  storage
MeowDB.js
Database in JSON (Node.JS Library)
Stars: ✭ 12 (-75%)
Mutual labels:  storage
cossync
腾讯云COS同步(批量上传)工具
Stars: ✭ 23 (-52.08%)
Mutual labels:  storage
sasutils
Serial Attached SCSI (SAS) Linux utilities and Python library
Stars: ✭ 36 (-25%)
Mutual labels:  storage
graphite-remote-adapter
Fully featured graphite remote adapter for Prometheus
Stars: ✭ 33 (-31.25%)
Mutual labels:  storage
Cherry-Node
Cherry Network's node implemented in Rust
Stars: ✭ 72 (+50%)
Mutual labels:  storage
talisman
Talisman helps with upgrade and wipe of a Portworx cluster on Kubernetes
Stars: ✭ 13 (-72.92%)
Mutual labels:  storage
ansible-unity
Ansible Modules for Dell EMC Unity
Stars: ✭ 19 (-60.42%)
Mutual labels:  storage
js-cfb
💾 OLE File Container Format
Stars: ✭ 54 (+12.5%)
Mutual labels:  storage
stoor
Storage wrapper with support for namespacing, timeouts and multi get/set and remove.
Stars: ✭ 26 (-45.83%)
Mutual labels:  storage
react-native-s3
React Native app to upload and display images from Amazon S3 using AWS Amplify as the back end service.
Stars: ✭ 41 (-14.58%)
Mutual labels:  storage
core
Javascript Object Storage Helper
Stars: ✭ 70 (+45.83%)
Mutual labels:  persistent-storage

ShoeBox

ShoeBox is a Kotlin library for object persistence that supports the observer pattern so your code can be notified immediately when stored data is changed.

Motivation

While it is a standalone library, ShoeBox was created as a persistence layer for Kweb applications, motivated by the lack of a simple persistence mechanism that supports the observer pattern. The idea is to create a "bridge" library between Shoebox and Kweb that will allow "binding" of UI components to persistent state, also known as the data mapper pattern. Here is a video illustrating this idea for TornadoFX on Android.

To emphasize, however, Shoebox doesn't depend on Kweb and should be useful for many other things.

Features

  • Functionality similar to MutableMap
  • Add listeners for object addition, deletion, and modification
  • Fairly comprehensive unit tests
  • Lightweight, pulls in very few dependencies
  • Materialized views
    • Efficiently retrieve objects by any specified key derived from the object
    • Similar to database indexes, but also supporting the observer pattern
  • Currently data is stored as uncompressed files, serialized to JSON

Limitations

  • Not very space efficient for small objects as files take up at least 4K on many filesystems
  • Data isn't currently compressed
  • Directories can't be shared between different Shoebox instances, although this is planned
    • Once this is supported we can use shared filesystems to scale horizontally, limited only by the filesystem
  • Doesn't implement the MutableMap interface
    • Even though the semantics are very similar to MutableMap, it isn't currently implemented because we wanted to avoid loading all data into memory.
    • This is probably solvable through custom implementations of MutableSet, MutableEntry and other interfaces, and will probably be done before 1.0 is released.

Adding to your project

Shoebox can be added easily to your Maven or Gradle project through Jitpack:

Release

As of release 0.4.0 Shoebox uses Kotlin Serialization, so you will also need to add the serialization plugin to your project.

Simple Usage Example

fun main() {
    val dir = Files.createTempDirectory("sb-")
    val userStore = shoebox(dir.resolve("users"), User.serializer())
    val usersByEmail = userStore.view("usersByEmail", User::email)
    val usersByGender = userStore.view("usersByGender", User::gender)

    userStore["ian"] = User("Ian Clarke", "male", "[email protected]")
    userStore["fred"] = User("Fred Smith", "male", "[email protected]")
    userStore["sue"] = User("Sue Smith", "female", "[email protected]")

    println(usersByEmail["[email protected]"])   // [User(name=Ian Clarke, gender=male, [email protected])]
    println(usersByGender["male"])          // [User(name=Ian Clarke, gender=male, [email protected]),
                                            // User(name=Fred Smith, gender=male, [email protected])]
    // note: view["xx]" returns a set of values
    usersByGender.onAdd("male") { kv ->
        println("${kv.key} became male")
    }
    usersByGender.onRemove("male") { kv ->
        println("${kv.key} ceased to be male")
    }

    userStore["fred"] = userStore["fred"]!!.copy(gender = "female") // Prints "fred ceased to be male"
}

@Serializable data class User(val name : String, val gender : String, val email : String)

Documentation

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].