|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.googlecode.objectify.util.Monotonic
public class Monotonic
Provides a method for generating contiguous, monotonically increasing values.
The datastore will automatically generate unique ids for your entities if you use a Long @Id value and create an object with a null id. Unfortunately this id is not guaranteed to increase monotonically, so you cannot use it for time-ordering. You also cannot use datestamps for time-ordering because clock skew among GAE instances is not guaranteed to fall within any particular bound; they could, in theory, be minutes off.
This class uses the memcache service to efficiently generate a monotonically increasing number which *can* be used for time-ordering. This can be used, for example, to create revision ids. It can also be used to generate the change numbers needed to keep a slave database in sync.
The data must be stored on a field of an entity. The field MUST be indexed.
Constructor Summary | |
---|---|
Monotonic()
|
Method Summary | |
---|---|
static long |
next(Objectify ofy,
java.lang.Class<?> entityClass,
java.lang.String fieldName)
Get the next unique, monotonically increasing, contiguous value for a field on an entity class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Monotonic()
Method Detail |
---|
public static long next(Objectify ofy, java.lang.Class<?> entityClass, java.lang.String fieldName)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |