8000 GitHub - StaticStudios/static-data
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

StaticStudios/static-data

Repository files navigation

What is static-data

static-data is an ORM built for a specific type of application. Origninally created for distributed Minecraft servers, this ORM avoids blocking an application's main thread when doing read or writes from a remote datasource. This is accomplished by keeping an in memory copy of the datasource, reading from there, and asynchronously disbatching writes to the datasource. The whole database is not kept in memory, only relevant tables are. This can use significant amounts of memory on large tables.

Built for distributed applications

What makes static-data special is that the in-memory cache is updated whenever the datasource is updated. This means that when one application instance makes a change, all other instances will update their cache. This avoids reading stale data. The various instaces do not have to contain the exact same data classes either, static-data receives updates based off of updated cells in the database. So if a cell is being tracked somewhere, the update will be received.

PostgreSQL only

This ORM only supports PostgreSQL. The reason is that static-data makes use of PostgreSQL's LISTEN / NOTIFY commands to recieve updates rather than add an additional layer between the application and the database.

static-data was designed to interop with other ORM's such as Hibernate. Not nessicarily within the same application, but if a secondary applicaition (that uses the same tables) such as a SpringBoot API is created, static-data does not have to be used there. Updates made with Hibernate will still be propogated to all application instances using static-data, since this is done on the database level.

Redis support

static-data supports using redis as a data source for simple values. Simple just means no collections/references. "Primative" types and complex types with custom ValueSerializers are supported here.

Data wrappers

  • PersistentValue.of(...): reference a column in a data object's row
  • PersistentValue.foreign(...): reference a column in a different table
  • CachedValue.of(...): reference an entry in redis (used when persistence doesn't matter)
  • Reference.of(...): reference another data object (one-to-one relationship)
  • PersistentCollection.of(...): represents a one-to-many relationship of simple data types such as Integer, Boolean, etc.. (like a PersistentValue, but one-to-many)
  • PersistentCollection.oneToMany(...): represents a one-to-many relationship of other data objects (like a Reference, but one-to-many)
  • PersistentCollection.manyToMany(...): represents a many-to-many relationship of other data objects, with the use of a junction table

Data types

Any class can be used as a data type, provided it's a "Primative" or a ValueSerializer has been registered for it. "Primitive" types are basic types which are supported in PostgreSQL. ValueSerializers must convert to and from complex types to a "Primative". Current "Primitive" types include: String, Character, Byte, Short, Integer, Long, Float, Double, Boolean, UUID, Timestamp and byte[]. null values are allowed for some "Primative" types. Specifically, null values are allowed for String, UUID, Timestamp, and byte[]. To avoid autoboxing/unboxing issues, wrappers for java primatives cannot be null.

Current limitations

Currently, static-data assumes that any column marked as an id column will not have its value changed. It should only ever be null when the row/data object doesn't exist. Changing this value will break things in many ways.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages

0