org.apache.torque.manager

## Class MethodResultCache

- java.lang.Object
- - org.apache.torque.manager.MethodResultCache

- Direct Known Subclasses:
    NoOpMethodResultCache

      public class MethodResultCache
      extends Object

  This class provides a cache for convenient storage of method results.
  Version:
    $Id: MethodResultCache.java 1870542 2019-11-28 09:32:40Z tv $
  Author:
    John McNally

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `MethodResultCache()` Allows subclasses to have ctors that do not require a cache.
    `` | `MethodResultCache(org.apache.commons.jcs.access.GroupCacheAccess<MethodCacheKey,Object> cache)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Clear the cache
    `<T> T` | `get(Serializable instanceOrClass, String method, Serializable... arg)` Get an object from the method cache
    `protected Object` | `getImpl(MethodCacheKey key)`
    `<T> void` | `put(T value, Serializable instanceOrClass, String method, Serializable... arg)` Put an object into the method cache
    `protected Object` | `putImpl(MethodCacheKey key, Object value)`
    `<T> T` | `remove(Serializable instanceOrClass, String method, Serializable... arg)` Remove object from method cache
    `void` | `removeAll(Serializable instanceOrClass, String method)` Remove all objects of the same group
    `protected Object` | `removeImpl(MethodCacheKey key)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MethodResultCache

          public MethodResultCache(org.apache.commons.jcs.access.GroupCacheAccess<MethodCacheKey,Object> cache)

      Constructor
      Parameters:
        `cache` - the cache instance to use

    - #### MethodResultCache

          protected MethodResultCache()

      Allows subclasses to have ctors that do not require a cache. This is used by NullMethodResultCache which has no-op versions of all methods.

  - ### Method Detail

    - #### clear

          public void clear()

      Clear the cache

    - #### getImpl

          protected Object getImpl(MethodCacheKey key)

    - #### putImpl

          protected Object putImpl(MethodCacheKey key,
                                   Object value)
                            throws TorqueException

      Throws:
        `TorqueException`

    - #### removeImpl

          protected Object removeImpl(MethodCacheKey key)

    - #### get

          public <T> T get(Serializable instanceOrClass,
                           String method,
                           Serializable... arg)

      Get an object from the method cache
      Type Parameters:
        `T` - type of the instance class
      Parameters:
        `instanceOrClass` - the Object on which the method is invoked. if the method is static, a String representing the class name is used.
        `method` - the method name
        `arg` - optional arguments for the method
      Returns:
        the object or null if it does not exist

    - #### put

          public <T> void put(T value,
                              Serializable instanceOrClass,
                              String method,
                              Serializable... arg)

      Put an object into the method cache
      Type Parameters:
        `T` - type of the instance class
      Parameters:
        `value` - the object to put into the cache
        `instanceOrClass` - the Object on which the method is invoked. if the method is static, a String representing the class name is used.
        `method` - the method name
        `arg` - optional arguments for the method

    - #### removeAll

          public void removeAll(Serializable instanceOrClass,
                                String method)

      Remove all objects of the same group
      Parameters:
        `instanceOrClass` - the Object on which the method is invoked. if the method is static, a String representing the class name is used.
        `method` - the method name

    - #### remove

          public <T> T remove(Serializable instanceOrClass,
                              String method,
                              Serializable... arg)

      Remove object from method cache
      Type Parameters:
        `T` - type of the instance class
      Parameters:
        `instanceOrClass` - the Object on which the method is invoked. if the method is static, a String representing the class name is used.
        `method` - the method name
        `arg` - optional arguments for the method
      Returns:
        the removed object

Copyright © 2000–2020 The Apache Software Foundation. All rights reserved.