AloFramework Cache 1.0 API
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • AloFramework
    • Cache
      • Clients
      • Config
  • PHP

Classes

  • CacheItem

Interfaces

  • ClientInterface

Exceptions

  • CacheException

Class CacheItem

A representation of a cached item

Namespace: AloFramework\Cache
Author: Art a.molcanovas@gmail.com
Located at CacheItem.php

Methods summary

public
# __construct( string $key = null, mixed $value = null, AloFramework\Cache\ClientInterface $client = null )

Constructor

Constructor

Parameters

$key
Immediately set the key
$value
Immediately set the value
$client
Store a reference to the client
public mixed
# __get( string $key )

Magic getter

Magic getter

Parameters

$key
key to get

Returns

mixed

Throws

InvalidArgumentException
when the key doesn't exist

Author

Art a.molcanovas@gmail.com
public
# __set( string $key, mixed $value )

Magic setter

Magic setter

Parameters

$key
Key to set
$value
Value to set

Throws

InvalidArgumentException
when the key doesn't exist

Author

Art a.molcanovas@gmail.com
public integer
# getLifetime( )

Returns the key lifetime

Returns the key lifetime

Returns

integer

Author

Art a.molcanovas@gmail.com
public boolean
# setLifetime( integer|DateTime $timeout )

Sets the cache item timeout

Sets the cache item timeout

Parameters

$timeout
Either the timeout in seconds or a DateTime object of when the key should expire

Returns

boolean

Author

Art a.molcanovas@gmail.com
public AloFramework\Cache\ClientInterface|null
# getClient( )

Returns the cache client instance

Returns the cache client instance

Returns

AloFramework\Cache\ClientInterface|null

Author

Art a.molcanovas@gmail.com
public AloFramework\Cache\CacheItem
# setClient( AloFramework\Cache\ClientInterface $client )

Sets the cache client

Sets the cache client

Parameters

$client

Returns

AloFramework\Cache\CacheItem

Author

Art a.molcanovas@gmail.com
public string
# getKey( )

Returns the set key

Returns the set key

Returns

string

Author

Art a.molcanovas@gmail.com
public AloFramework\Cache\CacheItem
# setKey( string $key )

Sets the key

Sets the key

Parameters

$key
The key

Returns

AloFramework\Cache\CacheItem

Author

Art a.molcanovas@gmail.com
public mixed
# getValue( )

Returns the value

Returns the value

Returns

mixed

Author

Art a.molcanovas@gmail.com
public AloFramework\Cache\CacheItem
# setValue( mixed $value )

Sets the value

Sets the value

Parameters

$value
The value

Returns

AloFramework\Cache\CacheItem

Author

Art a.molcanovas@gmail.com
public boolean
# exists( AloFramework\Cache\ClientInterface $server = null )

Checks if $this->key exists on the server

Checks if $this->key exists on the server

Parameters

$server
The server to use; if omitted, $this->client will be used

Returns

boolean

Throws

AloFramework\Cache\CacheException
If the client or the key isn't set

Author

Art a.molcanovas@gmail.com
public boolean
# delete( AloFramework\Cache\ClientInterface $server = null )

Delete the key from the server

Delete the key from the server

Parameters

$server
The server to use; if omitted; $this->client will be used

Returns

boolean
true if the key existed, false if it didn't

Throws

AloFramework\Cache\CacheException
If the client or the key isn't set

Author

Art a.molcanovas@gmail.com
public boolean
# saveToServer( AloFramework\Cache\ClientInterface $server = null )

Saves the item to the server

Saves the item to the server

Parameters

$server
The server to use; if omitted; $this->client will be used

Returns

boolean

Throws

AloFramework\Cache\CacheException
If the client or the key isn't set

Author

Art a.molcanovas@gmail.com
public boolean
# getFromServer( AloFramework\Cache\ClientInterface $server = null )

Sets $this->value & $this->lifetime from the server

Sets $this->value & $this->lifetime from the server

Parameters

$server
The server to fetch from; if omitted, $this->client will be used.

Returns

boolean
true if the key exists, false if it doesn't

Throws

AloFramework\Cache\CacheException
If the client or the key isn't set

Author

Art a.molcanovas@gmail.com

Uses

AloFramework\Cache\CacheItem::getLifetimeFromServer()
AloFramework\Cache\CacheItem::getValueFromServer()
public integer
# getLifetimeFromServer( AloFramework\Cache\ClientInterface $server = null )

Sets $this->lifetime from the server

Sets $this->lifetime from the server

Parameters

$server
The server to fetch from; of omitted, $this->client will be used

Returns

integer
the remaining lifetime if the key exists, 0 if it doesn't

Throws

AloFramework\Cache\CacheException
If the client or the key isn't set

Author

Art a.molcanovas@gmail.com

Used by

AloFramework\Cache\CacheItem::getFromServer()
public mixed|null
# getValueFromServer( AloFramework\Cache\ClientInterface $server = null )

Sets $this->value from the server

Sets $this->value from the server

Parameters

$server
The server to fetch from; of omitted, $this->client will be used

Returns

mixed|null
the value if the key exists, null if it doesn't

Throws

AloFramework\Cache\CacheException
If the client or the key isn't set

Author

Art a.molcanovas@gmail.com

Used by

AloFramework\Cache\CacheItem::getFromServer()

Properties summary

protected AloFramework\Cache\ClientInterface $client

The cache client

The cache client

#

Magic properties

public string $key

Cache item key

public mixed $value

Cache item value

public integer $lifetime

Cache item lifetime remaining

public AloFramework\Cache\ClientInterface $client

The cache client

AloFramework Cache 1.0 API API documentation generated by ApiGen