xplo.re Medusa Core Framework 3.2
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Event
  • Todo
  • Download

Namespaces

  • Core
    • Authentication
      • Auto
        • Driver
      • Driver
    • Cache
      • Driver
    • Charset
      • Driver
    • Configuration
      • Driver
    • Controller
    • Converter
      • Driver
    • Decoder
      • Driver
    • Encoder
      • Driver
    • Env
      • Authentication
      • Locale
      • Proxy
      • Server
        • HTTP
        • Redirect
        • X
    • Exception
    • Exchange
      • Driver
    • Fault
      • Formatter
        • Driver
      • Incident
        • Exception
      • Reporter
        • Driver
    • Field
    • Filter
      • Driver
    • Formatter
      • Driver
        • coreuimarkup
          • Token
    • Hash
    • Loader
    • Locale
    • Log
      • Driver
    • Module
      • Dependency
        • Requirement
          • Core
          • PHP
      • Linkage
        • Driver
    • PDF
    • Plugin
    • Query
      • Driver
    • Server
      • Driver
    • Session
      • Driver
    • Set
    • Storage
      • Driver
      • Field
        • Element
    • Stream
      • Driver
    • String
    • Translation
      • Driver
      • Language
        • Driver
    • Type
    • URI
      • Driver
    • Version
    • View
      • Driver
        • coreui
          • Control
            • Button
            • Table
          • Element
        • htmlbuilder
          • Tags
        • yui
          • Modules
  • None
  • PHP

Classes

  • apc
  • file
  • null
  • storage

Class file

Manages file-system based caching.

Metadata is stored at the beginning of each cache file with the following data fields. See $seekOffset to skip to the cache entry data:

  • Timestamp of last modification (32-bit unsigned integer, little-endian),

  • time to live in seconds (32-bit unsigned integer, little-endian),

  • MD5 hash of file contents (16 bytes).

Implementations should however not rely on the format of stream headers and use the access methods provided by this driver.

Core\Object implements Core\Chainable
Extended by Core\Set implements Core\Accessor
Extended by Core\Cache
Extended by Core\Cache\Driver\file
Namespace: Core\Cache\Driver
Package: Core\Cache
Since: 3.0
Requires: PHP 5.3
Version: 1.1
Located at Cache/Driver/file.inc.php

Methods summary

public
# __construct( Core\URI\Driver\file $uri )

Parameters

$uri
Driver configuration URI.

Since

3.0

Overrides

Core\Cache::__construct
public boolean
# exists( string $class, string $key )

Tests, whether a cache entry for a class item exists.

Tests, whether a cache entry for a class item exists.

Parameters

$class
Cache class of item to test for.
$key
The item key to test for.

Returns

boolean

true, if a cache entry for the requested item exists, otherwise false.

Since

3.0
public string
# get( string $class, string $key )

Reads a cache entry and returns all binary data for the entry.

Reads a cache entry and returns all binary data for the entry.

Parameters

$class
Class of cache item.
$key
The key of the cache item.

Returns

string
Binary data string of cache entry.

Since

3.0

Overrides

Core\Cache::get
public string
# getHash( string $class, string $key )

Returns the hash for the requested cache entry. The hash type depends on the backend in use and defaults to 16-byte binary MD5.

Returns the hash for the requested cache entry. The hash type depends on the backend in use and defaults to 16-byte binary MD5.

Parameters

$class
Class of cache item.
$key
The key of the cache item.

Returns

string
Binary hash of cache element.

Since

3.1

Overrides

Core\Cache::getHash
public Core\Stream
# getStream( string $class, string $key )

Returns a reading stream instance for the requested cache entry.

Returns a reading stream instance for the requested cache entry.

Parameters

$class
Class of cache item.
$key
The key of the cache item.

Returns

Core\Stream
Reading Stream instance for the requested cache entry.

Remark

Avoid absolute seek positions; the file cache backend stores metadata at the beginning of the stream (see $seekOffset).


See

$seekOffset

Since

3.0
public integer
# getTimestamp( string $class, string $key )

Returns a UNIX timestamp of the last cache entry modification.

Returns a UNIX timestamp of the last cache entry modification.

Parameters

$class
Class of cache item.
$key
The key of the cache item.

Returns

integer
UNIX timestamp of last modification to the named cache entry.

Since

3.1
public
# put( string $class, string $key, string $binaryData, integer $ttl = Core\Cache\Driver\null )

Writes binary data to a specified cache entry.

Writes binary data to a specified cache entry.

Parameters

$class
Class of cache item.
$key
The key of the cache item.
$binaryData
Binary data string to write to the cache entry.
$ttl

Time to live for cache entry (in seconds). Set to null if entry does not timeout.

Since

3.0

Overrides

Core\Cache::put
public Core\Stream
# putStream( string $class, string $key, integer $ttl = Core\Cache\Driver\null )

Returns a writing stream instance for the requested cache entry.

Returns a writing stream instance for the requested cache entry.

Parameters

$class
Class of cache item.
$key
The key of the cache item.
$ttl

Time to live for cache entry (in seconds). Set to null if entry does not timeout.

Returns

Core\Stream
Writing Stream instance for the requested cache entry.

Remark

Avoid absolute seek positions; the file cache backend stores metadata at the beginning of the stream (see $seekOffset).


See

$seekOffset

Since

3.0
public
# remove( string $class, string $key )

Deletes a cache key entry. If the entry does not exist, no operation is performed.

Deletes a cache key entry. If the entry does not exist, no operation is performed.

Parameters

$class
Class of cache item.
$key
The key of the cache item.

Since

3.1
public string
# targetFile( string $class, string $key, boolean $initClassPath = false )

Computes the cache target file name.

Computes the cache target file name.

Parameters

$class
Class of cache entry.
$key
Key of cache entry.
$initClassPath

Automatically initialises subdirectories as required; should only be used if a cache file is created, not if existence is checked.

Returns

string
Target file name string of given cache class and key name.

Throws

Core\Exception\InvalidArgument
Failed to create cache subdirectory or directory is not writable.

Since

3.0

Methods inherited from Core\Cache

activate(), active(), autocreate(), defaultInstance(), getAge(), getMeta(), getVar(), putVar(), setVersionID(), unify()

Methods inherited from Core\Set

__get(), __isset()

Methods inherited from Core\Object

__autocreateFactory(), __call(), __processParameters(), __toString(), attachMethod(), chain(), getValueForKey(), getValueForKeyPath(), getValueForUndefinedKey(), hash(), issetValueForKey(), setValueForKey(), setValueForKeyPath(), setValueForUndefinedKey(), uuid()

Constants summary

string SubdirectoryCharactersParameter

Sets the number of key characters used for subdirectory levels. Only used if a subdirectory level >0 is defined. Default value is 2, maximum allowed value is 3 (minimum is 1).

Sets the number of key characters used for subdirectory levels. Only used if a subdirectory level >0 is defined. Default value is 2, maximum allowed value is 3 (minimum is 1).

The number of characters per subdirectory level controls the maximum number of subdirectories per level. Usually hexadecimal characters are used for cache keys, hence a subdirectory character length of 1 yields at most 16 subdirectories per level. A length of 2 yields 256 subdirectories per level, which is the default and for most file systems a sensible value. A length of 3 yields 4096 subdirectories per level and is recommended for high-performance file systems with high cache usage.

Since

3.1
# 'sub-chars'
string SubdirectoryLevelParameter

Controls the number of subdirectories created for cached items. Default value is 0 (no subdirectories are created). Maximum allowed value is 8.

Controls the number of subdirectories created for cached items. Default value is 0 (no subdirectories are created). Maximum allowed value is 8.

Several systems suffer from performance loss if directories contain too many files. Additionally, the maximum number of allowed files per directory is restricted by many file systems, e.g. NTFS only allows up to 65534 files per directory.

A sensitive choice are 2 or 3 levels, depending on the amount of cached items and the underlying system.

Since

3.1
# 'sub-level'
string SubdirectoryModeParameter

Default directory mode used for subdirectories. Defaults to 0777.

Default directory mode used for subdirectories. Defaults to 0777.

Expects an octal value. This parameter is ignored on Windows.

Since

3.1
# 'sub-mode'

Constants inherited from Core\Cache

SharedClass

Constants inherited from Core\Object

AnyParameterType, AutochainParameterType, AutocreateParameterType, BooleanParameterType, CharParameterType, EnumParameterType, IntegerParameterType, RealParameterType, StringParameterType, UserParameterType

Properties summary

protected array $_v_parameters

File cache settings array.

File cache settings array.

Since

3.1
#
protected string $_v_path

Storage path root directory.

Storage path root directory.

Since

3.0
#
protected integer $_v_seekOffset

Size of file headers to add to seek to absolute positions in streams.

Size of file headers to add to seek to absolute positions in streams.

Since

3.1
# 24

Properties inherited from Core\Cache

$_activeInstance, $_v_versionID

Magic properties

public read-only array $parameters

Driver configuration array.

public read-only string $path

Storage root for storing cache entries.

public read-only integer $seekOffset

Size of file header meta data of stored cache entries.

Magic properties inherited from Core\Cache

$versionID

Magic properties inherited from Core\Object

$hash, $uuid

xplo.re Medusa Core Framework 3.2 API documentation generated by ApiGen