Interface ORecordCache

All Known Implementing Classes:
OAbstractMapCache, ORecordCacheSoftRefs, ORecordCacheWeakRefs

public interface ORecordCache
Generic cache interface that should be implemented in order to plug-in custom cache. Also implementing class has to have public one-arg constructor to set cache limit. For example, next class can be safely used as plug-in cache:
   public class CustomCache implements OCache {
     public CustomCache(int initialLimit) {
       // some actions to do basic initialization of cache instance
       ...
     }

     //implementation of interface
     ...
   }
 
As reference implementation used ORecordCacheWeakRefs
Author:
Maxim Fedorov
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Remove all records from cache
    void
     
    boolean
    Disable cache.
    boolean
    Enable cache
    get(ORID id)
    Look up for record in cache by it's identifier
    boolean
    Tell whether cache is enabled
    Keys of all stored in cache records
    put(ORecord record)
    Push record to cache.
    Remove record with specified identifier
    void
    All operations running at cache destruction stage
    int
    Total number of stored records
    void
    All operations running at cache initialization stage
  • Method Details

    • startup

      void startup()
      All operations running at cache initialization stage
    • shutdown

      void shutdown()
      All operations running at cache destruction stage
    • isEnabled

      boolean isEnabled()
      Tell whether cache is enabled
      Returns:
      true if cache enabled at call time, otherwise - false
    • enable

      boolean enable()
      Enable cache
      Returns:
      true - if enabled, false - otherwise (already enabled)
    • disable

      boolean disable()
      Disable cache. None of record management methods will cause effect on cache in disabled state. Only cache info methods available at that state.
      Returns:
      true - if disabled, false - otherwise (already disabled)
    • get

      ORecord get(ORID id)
      Look up for record in cache by it's identifier
      Parameters:
      id - unique identifier of record
      Returns:
      record stored in cache if any, otherwise - null
    • put

      ORecord put(ORecord record)
      Push record to cache. Identifier of record used as access key
      Parameters:
      record - record that should be cached
      Returns:
      previous version of record
    • remove

      ORecord remove(ORID id)
      Remove record with specified identifier
      Parameters:
      id - unique identifier of record
      Returns:
      record stored in cache if any, otherwise - null
    • clear

      void clear()
      Remove all records from cache
    • size

      int size()
      Total number of stored records
      Returns:
      non-negative number
    • keys

      Collection<ORID> keys()
      Keys of all stored in cache records
      Returns:
      keys of records
    • clearRecords

      void clearRecords()