XMF Cookbook
  • Introduction
  • XMF Cookbook
  • Basic Ingredients
    • Namespaces
    • Autoloading
    • Debugging
    • Forward Compatibility
  • Recipes
    • Introducing Module Helpers
    • Using the Permission Helper
      • Checking Permissions
      • Managing Item Permissions
    • Using the Session Helper
    • Using JSON Web Tokens
    • Altering Database Tables
    • Migrating a Module's Database
    • Loading Initial Data
    • Module Admin Pages
      • Hide and Seek with Icons
      • Standard Admin Pages
    • Manage Metadata
    • Highlighting Content
  • Reference
    • Assert
      • Assertions
    • Database
      • Migrate
      • TableLoad
      • Tables
        • Getting Started
        • Table Operations
        • Working with Columns
        • Working with Indexes
        • Changing Table Data
        • Interacting with the Work Queue
        • Error Info and Debugging
    • Debug
    • FilterInput
    • Highlighter
    • IPAddress
    • Jwt
      • JsonWebToken
      • KeyFactory
      • TokenFactory
      • TokenReader
    • Key
      • ArrayStorage
      • Basic
      • FileStorage
      • KeyAbstract
      • StorageInterface
    • Language
    • Metagen
      • Extracting Data
      • Applying Data
    • Module
      • Admin
      • Helper
      • Helper
        • AbstractHelper
        • Cache
        • GenericHelper
        • Permission
        • Session
    • ProxyCheck
    • Random
    • Request
    • StopWords
    • Uuid
    • Yaml
  • Credits
  • License:
  • Table of Content
Powered by GitBook
On this page
  • new Cache($dirname)
  • write($key, $value, $ttl)
  • read($key, $default)
  • delete($key)
  • cacheRead($key, $regenFunction, $ttl, $args)
  1. Reference
  2. Module
  3. Helper

Cache

PreviousAbstractHelperNextGenericHelper

Last updated 7 years ago

The Xmf\Module\Helper\Cache class is a module aware helper for using the system cache for module related data. The underlying cache is a key value store. This helper isolates the module related data by applying a module specific prefix to each key.

Xmf\Module\Helper\Cache extends .

new Cache($dirname)

Creates the cache helper for the module specified by name as $dirname. If the string $dirname is empty, the current module in XOOPS will be used.

write($key, $value, $ttl)

Write the value $value for a key named $key to the cache, using the specified number of seconds in $ttl as the time to live.

read($key, $default)

Read value for the key named $key from the cache. If the key does not exist, it returns $default, or false if $default was not specified.

delete($key)

Deletes any key named $key from the cache.

cacheRead($key, $regenFunction, $ttl, $args)

The cacheRead() method combines reading and any needed regenerating of the cache entry into a single call.

First, it attempts to read the cache entry for $key, and returns it if found.

If the cache read fails, it calls the specified callable, $regenFunction, passing to it any variable arguments, $args. It writes the return of $regenFunction to the cache for $key with time to live $ttl, and returns the new cached value to the caller.

Xmf\Module\Helper\AbstractHelper