Skip to content

Storage Service

Shane Isbell edited this page Aug 19, 2017 · 1 revision

OulipoMachine uses a Java port of LevelDB for storing of user information. LevelDB stores entries lexicographically sorted by keys.

Layered on top of LevelDB is the Oulipo Storage Service. The Storage Service is Java data access API that maps Java objects to and from the LevelDB byte storage.

Advantages include:

  • Simple API
  • Easy to store and retrieve models (schema-less)
  • Fast embedded data access

Storage Service

Defining Objects

A simple object

import java.util.Date;
import org.oulipo.machine.storage.Id;

public class TempToken  {
	@Id
	public String id; 
	public Date created;
	public Boolean isUsed;
	
	public TempToken() { }
	
	public TempToken(String id, Date created, Boolean isUsed) {
		this.id = id;
		this.created = created;
		this.isUsed = isUsed;
	}
}

Operations

Saving

StorageService service = new StorageService("oulipo");
TempToken token = new TempToken("234", new Date(), false);
storage.save(token);`

Loading

StorageService service = new StorageService("oulipo");
TempToken token = storage.load("234", TempToken.class);`

References

Clone this wiki locally