Class HazelcastRepository<K,T extends Identifiable<K>>

java.lang.Object
edu.yu.marketmaker.memory.HazelcastRepository<K,T>
Type Parameters:
K - the key type
T - the entity type, must implement Identifiable
All Implemented Interfaces:
Repository<K,T>

public class HazelcastRepository<K,T extends Identifiable<K>> extends Object implements Repository<K,T>
Generic Hazelcast-backed implementation of Repository. Uses a distributed IMap for storage with write-through persistence to the database via the configured MapStore.
  • Constructor Details

    • HazelcastRepository

      public HazelcastRepository(com.hazelcast.map.IMap<K,T> map)
      Constructor for HazelcastRepository.
      Parameters:
      map - that this class will wrap
  • Method Details

    • get

      public Optional<T> get(K id)
      Get mapped value
      Specified by:
      get in interface Repository<K,T extends Identifiable<K>>
      Parameters:
      id - key of the entity
      Returns:
    • put

      public void put(T entity)
      Store entity
      Specified by:
      put in interface Repository<K,T extends Identifiable<K>>
      Parameters:
      entity - to be stored
    • getAll

      public Collection<T> getAll()
      Get all mapped values
      Specified by:
      getAll in interface Repository<K,T extends Identifiable<K>>
      Returns:
      Collection of all entities
    • delete

      public void delete(K id)
      Delete entity
      Specified by:
      delete in interface Repository<K,T extends Identifiable<K>>
      Parameters:
      id - key of the entity
    • getMap

      protected com.hazelcast.map.IMap<K,T> getMap()
      Returns the underlying IMap for advanced operations.
      Returns:
      the Hazelcast IMap