This page describes an older version of the product. The latest stable version is 16.4.

Unique Index

Unique constraints can be defined for an attribute or attributes of a space class. This will ensure that only one instance of the space class exists in the space with the specific attribute value. These indexes are applicable to all types of index; Basic, Extended, Compound and Collection indices.


The uniqueness is enforced per partition and not over the whole cluster.


When the system encounters a unique constraint violation in one of the index-changing api calls (write/update/change) a UniqueConstraintViolationException is thrown.

The operation which caused the violation is rolled back with the following effects:

Operation Action
write the entry is removed
update the original value is restored
change the original value is restored
If the operation(write or update) is performed under a transaction, the unique value check is done when the operation is performed (eager mode) and not when the transaction is committed.


A unique attribute is added to the [SpaceIndex] annotation. Unique = true will designate a unique constraint.


public class Person

    public String FirstName{ get; set;}

    [SpaceIndex(Type=SpaceIndexType.Basic, Unique=true)]
    public String LastName{ get; set; }

    public int? Age{ get; set; }
    <class name="Gigaspaces.Examples.Person"
        persist="false" replicate="false" fifo="false" >
        <property name="lastName">
            <index type="BASIC" unique="true"/>
        <property name="firstName">
            <index type="BASIC"/>
        <property name="age">
             <index type="EXTENDED"/>


  • Supported only with ALL_IN_CACHE cache policy, not supported with LRU and other evict able cache policies
  • Not supported for local-cache/local-view since its only per-partition enforcement
  • Currently not supported for dynamic (on-the-fly) indices.