GithubHelp home page GithubHelp logo

ingensi / storeit Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 2.0 350 KB

Light package used to store entities to various storage.

Home Page: http://storeit.ingensi.ninja

License: MIT License

Java 100.00%

storeit's Introduction

StoreIt

Light Java library used to store entities to various storage.

How to use!

StoreIt provides an abstraction layer to store, get, list, update and delete all kind of entities.

To allow an entity to be stored into a StoreIt storage, it has to implement StoredEntity interface, to provides a getId() method.

Build with maven

Form the root package, install StoredIt locally:

mvn install

Add dependency in your project

Add dependency in your pom.xml according to the storage your want to use:

<dependency>
    <groupId>com.ingensi.data</groupId>
    <artifactId>storeit-elasticsearch</artifactId>
    <version>${storeit.version}</version>
</dependency>

Store your first entities

To store an entity with StoreIt, you need a StoredEntity class. Here is an example with a User class:

public class User implements StoredEntity {
    private final String username;
    private final String firstname;
    private final String lastname;
    
    public User(String username, String firstname, String lastname) {
        this.username = username;
        this.firstname = firstname;
        this.lastname = lastname;
    }
    
    public String getUsername() {
        return username;
    }
    
    public String getFirstname() {
        return firstname;
    }
    
    public String getLastname() {
        return lastname;
    }
    
    @Override
    public String getId() {
        return username;
    }
}

Then you are able to create, get, list, update or delete User into various storage by instantiating a Storage<User>:

Storage<User> storage = new xxxStorage<>(
    // DEPENDS ON THE STORAGE IMPLEMENTATION
);

// store new user
storage.store(new User("fbar", "foo", "bar"));
// list all users
Collection<User> users = storage.list();
// update user
storage.store(new User("fbar", "Jason", "Wilson"));
// get specific user
User bob = storage.get("bob");
// delete a user
storage.delete("fbar");

Structure and implementations

Each implemented module contains its own specific documentation.

Implement your own Storage

Look at existing implementations to learn how to implement your own Storage. Don't forget to contribute :)

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.