Class KObjectCache

java.lang.Object
com.kheops.util.KObjectCache

public class KObjectCache extends Object
A class used to store and retrieve data stored on memory.
  • Constructor Summary

    Constructors
    Constructor
    Description
    KObjectCache(int maximumSize)
    Constructs a KMemoryDataCache with the specified maximum size
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if the table contains the data with the specified keys
    long
    Gets the memory cache current size
    double
    This method returns the sucessfull retrieval data count over the number of retrieval attemps It enables to get statistic of the retrieve method
    long
    Gets the memory cache maximum allowed size
    void
    Removes the memory cache with the specified key
    Retrieves the data previously stored using the specified key.
    void
    store(String key, Object object)
    Stores the specified object in memory cache using the specified key.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • KObjectCache

      public KObjectCache(int maximumSize)
      Constructs a KMemoryDataCache with the specified maximum size
      Parameters:
      maximumSize - the maximum number of objects the cache can contain
  • Method Details

    • store

      public void store(String key, Object object)
      Stores the specified object in memory cache using the specified key.
      Parameters:
      key - the key of the KMemoryDataCache where to store the data
      object - the object to be stored
    • retrieve

      public Object retrieve(String key)
      Retrieves the data previously stored using the specified key. If the data does not exist, no exception is thrown but the method returns null.
      Parameters:
      key - unique identifier used to search for the corresponding data
      Returns:
      data the data retrieved from memory
      this method keeps the count of sucessfull and unsecessfull data retrieval
    • contains

      public boolean contains(String key)
      Checks if the table contains the data with the specified keys
      Parameters:
      key - the corresponding key
      Returns:
      the boolean value of the result
    • getCurrentSize

      public long getCurrentSize()
      Gets the memory cache current size
      Returns:
      the current cache size
    • getMaximumSize

      public long getMaximumSize()
      Gets the memory cache maximum allowed size
      Returns:
      the maximum cache size
    • remove

      public void remove(String key)
      Removes the memory cache with the specified key
      Parameters:
      key - the key of the data to be removed
    • getEfficiency

      public double getEfficiency()
      This method returns the sucessfull retrieval data count over the number of retrieval attemps It enables to get statistic of the retrieve method
      Returns:
      the effeciency ratio