wirebox.system.cache.providers

Class MockProvider

lucee.Component
    extended by wirebox.system.cache.AbstractCacheBoxProvider
      extended by wirebox.system.cache.providers.MockProvider
All Implemented Interfaces:
IColdBoxProvider

Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com ---- A mock cache provider that keeps cache data in a simple map for testing and assertions

Class Attributes:
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • serializable : false
  •  
  • luis : Majano
  •  
    Property Summary
    type property default serializable required
    struct cache
          The in memory mocking cache.

    • access = public
    • returntype = any
    true false
    Constructor Summary
    init()
          Constructor.
    Method Summary
    boolean clear(any objectKey)
         Clears an object from the cache by using its cache key.
    any clearAll()
         Clear all the cache elements from the cache.
    any clearAllEvents([boolean async='false'])
         Clears all events from the cache.
    any clearAllViews([boolean async='false'])
         Clears all views from the cache.
    any clearEvent(any eventSnippet, [any queryString=''])
         Clears all the event permutations from the cache according to snippet and querystring.
    any clearEventMulti(any eventsnippets, [any queryString=''])
         Clears all the event permutations from the cache according to the list of snippets and querystrings.
    boolean clearQuiet(any objectKey)
         Clears an object from the cache by using its cache key.
    any clearView(any viewSnippet)
         Clears all view name permutations from the cache according to the view name.
    any clearViewMulti(any viewSnippets)
         Clears all view name permutations from the cache according to the view name.
    any configure()
         This method makes the cache ready to accept elements and run.
    any expireAll()
         Expire all the elements in the cache (if supported by the provider).
    any expireObject(any objectKey)
         Expires an object from the cache by using its cache key.
    any get(any objectKey)
         Get an object from the cache and updates stats.
    string getCache()
    struct getCachedObjectMetadata(any objectKey)
         Get a cache objects metadata about its performance.
    any getColdbox()
         Get the coldbox application reference as wirebox.
    any getEventCacheKeyPrefix()
         Get the event cache key prefix which is necessary for event caching.
    any getEventURLFacade()
         Get the event caching URL facade utility that determines event caching.
    array getKeys()
         Returns a list of all elements in the cache, whether or not they are expired.
    any getObjectStore()
         If the cache provider implements it, this returns the cache's object store as type: wirebox.
    any getQuiet(any objectKey)
         Get an object from the cache without updating stats or listeners.
    numeric getSize()
         Get the number of elements in the cache.
    struct getStoreMetadataKeyMap()
         Get a key lookup structure where cachebox can build the report on.
    struct getStoreMetadataReport()
         Get a structure of all the keys in the cache with their appropriate metadata structures.
    any getViewCacheKeyPrefix()
         Get the cached view key prefix which is necessary for view caching.
    boolean isExpired(any objectKey)
         Has the object key expired in the cache.
    boolean lookup(any objectKey)
         Check if an object is in cache, if not found it records a miss.
    boolean lookupQuiet(any objectKey)
         Check if an object is in cache, no stats updated or listeners.
    boolean lookupValue(any objectValue)
         Check if an object is in cache, if not found it records a miss.
    any reap()
         Send a reap or flush command to the cache.
    any set(any objectKey, any object, [any timeout], [any lastAccessTimeout], [struct extra])
         Sets an object in the cache and returns an instance of itself.
    any setCache(struct cache)
    any setColdBox(any<wirebox.system.web.Controller> coldbox)
         Set the ColdBox linkage into the provider.
    any setQuiet(any objectKey, any object, [any timeout], [any lastAccessTimeout], [struct extra])
         Sets an object in the cache with no event calls and returns an instance of itself.
    any shutdown()
         Shutdown command issued when CacheBox is going through shutdown phase.
     
    Methods inherited from class wirebox.system.cache.AbstractCacheBoxProvider
    clearByKeySnippet, clearMulti, clearStatistics, getCacheFactory, getCacheId, getCachedObjectMetadataMulti, getConfiguration, getEnabled, getEventManager, getMemento, getMulti, getName, getOrSet, getReportingEnabled, getStats, getUtility, getUuidHelper, inThread, isEnabled, isReportingEnabled, lookupMulti, randomUUID, setCacheFactory, setCacheId, setConfiguration, setEnabled, setEventManager, setMulti, setName, setReportingEnabled, setStats, setUtility, setUuidHelper, statusCheck, validateConfiguration
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()

    Constructor


    Property Detail

    cache

    property struct cache

    The in memory mocking cache

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    Method Detail

    clear

    public boolean clear(any objectKey)

    Clears an object from the cache by using its cache key. Returns false if object was not removed or did not exist anymore

    Specified by:
    clear in interface ICacheProvider
    Parameters:
    objectKey - The object cache key

    clearAll

    public any clearAll()

    Clear all the cache elements from the cache

    Specified by:
    clearAll in interface ICacheProvider
    Returns:
    MockProvider

    clearAllEvents

    public any clearAllEvents([boolean async='false'])

    Clears all events from the cache.

    Specified by:
    clearAllEvents in interface IColdBoxProvider
    Parameters:
    async - If implemented, determines async or sync clearing.
    Returns:
    MockProvider

    clearAllViews

    public any clearAllViews([boolean async='false'])

    Clears all views from the cache.

    Specified by:
    clearAllViews in interface IColdBoxProvider
    Parameters:
    async - Run command asynchronously or not
    Returns:
    MockProvider

    clearEvent

    public any clearEvent(any eventSnippet, [any queryString=''])

    Clears all the event permutations from the cache according to snippet and querystring. Be careful when using incomplete event name with query strings as partial event names are not guaranteed to match with query string permutations

    Specified by:
    clearEvent in interface IColdBoxProvider
    Parameters:
    eventSnippet - The event snippet to clear on. Can be partial or full
    queryString - If passed in, it will create a unique hash out of it. For purging purposes
    Returns:
    MockProvider

    clearEventMulti

    public any clearEventMulti(any eventsnippets, [any queryString=''])

    Clears all the event permutations from the cache according to the list of snippets and querystrings. Be careful when using incomplete event name with query strings as partial event names are not guaranteed to match with query string permutations

    Specified by:
    clearEventMulti in interface IColdBoxProvider
    Parameters:
    eventsnippets
    queryString - The comma-delimited list of queryStrings passed in. If passed in, it will create a unique hash out of it. For purging purposes. If passed in the list length must be equal to the list length of the event snippets passed in
    Returns:
    MockProvider

    clearQuiet

    public boolean clearQuiet(any objectKey)

    Clears an object from the cache by using its cache key. Returns false if object was not removed or did not exist anymore without doing statistics or updating listeners

    Specified by:
    clearQuiet in interface ICacheProvider
    Parameters:
    objectKey - The object cache key

    clearView

    public any clearView(any viewSnippet)

    Clears all view name permutations from the cache according to the view name

    Specified by:
    clearView in interface IColdBoxProvider
    Parameters:
    viewSnippet - The view name snippet to purge from the cache
    Returns:
    MockProvider

    clearViewMulti

    public any clearViewMulti(any viewSnippets)

    Clears all view name permutations from the cache according to the view name.

    Specified by:
    clearViewMulti in interface IColdBoxProvider
    Parameters:
    viewSnippets - The comma-delimited list or array of view snippet to clear on. Can be partial or full

    configure

    public any configure()

    This method makes the cache ready to accept elements and run. Usually a cache is first created (init), then wired and then the factory calls configure() on it

    Specified by:
    configure in interface ICacheProvider
    Returns:
    MockProvider

    expireAll

    public any expireAll()

    Expire all the elements in the cache (if supported by the provider)

    Specified by:
    expireAll in interface ICacheProvider

    expireObject

    public any expireObject(any objectKey)

    Expires an object from the cache by using its cache key. Returns false if object was not removed or did not exist anymore (if supported by the provider)

    Specified by:
    expireObject in interface ICacheProvider
    Parameters:
    objectKey - The object cache key
    Returns:
    MockProvider

    get

    public any get(any objectKey)

    Get an object from the cache and updates stats

    Specified by:
    get in interface ICacheProvider
    Parameters:
    objectKey - The key to retrieve

    getCache

    public string getCache()


    getCachedObjectMetadata

    public struct getCachedObjectMetadata(any objectKey)

    Get a cache objects metadata about its performance. This value is a structure of name-value pairs of metadata.

    Specified by:
    getCachedObjectMetadata in interface ICacheProvider
    Parameters:
    objectKey - The key to retrieve

    getColdbox

    public any getColdbox()

    Get the coldbox application reference as wirebox.system.web.Controller

    Specified by:
    getColdbox in interface IColdBoxProvider
    Returns:
    wirebox.system.web.Controller

    getEventCacheKeyPrefix

    public any getEventCacheKeyPrefix()

    Get the event cache key prefix which is necessary for event caching

    Specified by:
    getEventCacheKeyPrefix in interface IColdBoxProvider

    getEventURLFacade

    public any getEventURLFacade()

    Get the event caching URL facade utility that determines event caching

    Specified by:
    getEventURLFacade in interface IColdBoxProvider
    Returns:
    wirebox.system.cache.util.EventURLFacade

    getKeys

    public array getKeys()

    Returns a list of all elements in the cache, whether or not they are expired

    Specified by:
    getKeys in interface ICacheProvider

    getObjectStore

    public any getObjectStore()

    If the cache provider implements it, this returns the cache's object store as type: wirebox.system.cache.store.IObjectStore

    Specified by:
    getObjectStore in interface ICacheProvider
    Returns:
    wirebox.system.cache.store.IObjectStore

    getQuiet

    public any getQuiet(any objectKey)

    Get an object from the cache without updating stats or listeners

    Specified by:
    getQuiet in interface ICacheProvider
    Parameters:
    objectKey - The key to retrieve

    getSize

    public numeric getSize()

    Get the number of elements in the cache

    Specified by:
    getSize in interface ICacheProvider

    getStoreMetadataKeyMap

    public struct getStoreMetadataKeyMap()

    Get a key lookup structure where cachebox can build the report on. Ex: [timeout=timeout,lastAccessTimeout=idleTimeout]. It is a way for the visualizer to construct the columns correctly on the reports

    Specified by:
    getStoreMetadataKeyMap in interface ICacheProvider

    getStoreMetadataReport

    public struct getStoreMetadataReport()

    Get a structure of all the keys in the cache with their appropriate metadata structures. This is used to build the reporting.[keyX->[metadataStructure]]

    Specified by:
    getStoreMetadataReport in interface ICacheProvider

    getViewCacheKeyPrefix

    public any getViewCacheKeyPrefix()

    Get the cached view key prefix which is necessary for view caching

    Specified by:
    getViewCacheKeyPrefix in interface IColdBoxProvider

    isExpired

    public boolean isExpired(any objectKey)

    Has the object key expired in the cache

    Specified by:
    isExpired in interface ICacheProvider
    Parameters:
    objectKey - The key to retrieve

    lookup

    public boolean lookup(any objectKey)

    Check if an object is in cache, if not found it records a miss.

    Specified by:
    lookup in interface ICacheProvider
    Parameters:
    objectKey - The key to retrieve

    lookupQuiet

    public boolean lookupQuiet(any objectKey)

    Check if an object is in cache, no stats updated or listeners

    Specified by:
    lookupQuiet in interface ICacheProvider
    Parameters:
    objectKey - The key to retrieve

    lookupValue

    public boolean lookupValue(any objectValue)

    Check if an object is in cache, if not found it records a miss.

    Parameters:
    objectValue - The value to retrieve

    reap

    public any reap()

    Send a reap or flush command to the cache

    Specified by:
    reap in interface ICacheProvider
    Returns:
    MockProvider

    set

    public any set(any objectKey, any object, [any timeout], [any lastAccessTimeout], [struct extra])

    Sets an object in the cache and returns an instance of itself

    Specified by:
    set in interface ICacheProvider
    Parameters:
    objectKey - The object cache key
    object - The object to cache
    timeout - The timeout to use on the object (if any, provider specific)
    lastAccessTimeout - The idle timeout to use on the object (if any, provider specific)
    extra - A map of name-value pairs to use as extra arguments to pass to a providers set operation
    Returns:
    MockProvider

    setCache

    public any setCache(struct cache)

    Parameters:
    cache

    setColdBox

    public any setColdBox(any<wirebox.system.web.Controller> coldbox)

    Set the ColdBox linkage into the provider

    Specified by:
    setColdBox in interface IColdBoxProvider
    Parameters:
    coldbox - The ColdBox controller
    Returns:
    MockProvider

    setQuiet

    public any setQuiet(any objectKey, any object, [any timeout], [any lastAccessTimeout], [struct extra])

    Sets an object in the cache with no event calls and returns an instance of itself

    Specified by:
    setQuiet in interface ICacheProvider
    Parameters:
    objectKey - The object cache key
    object - The object to cache
    timeout - The timeout to use on the object (if any, provider specific)
    lastAccessTimeout - The idle timeout to use on the object (if any, provider specific)
    extra - A map of name-value pairs to use as extra arguments to pass to a providers set operation
    Returns:
    MockProvider

    shutdown

    public any shutdown()

    Shutdown command issued when CacheBox is going through shutdown phase

    Specified by:
    shutdown in interface ICacheProvider
    Returns:
    MockProvider