Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
Asset_Cache Class Reference
Inheritance diagram for Asset_Cache:
MySource_Object

Public Member Functions

 Asset_Cache ()
 
 setSizeRules ($size=-1, $all_items=false)
 
 add ($item, $itemid=-1)
 
 get ($itemid)
 
 release ($itemid)
 
 _applySizeRules ()
 
 remove ($itemid, $force=false)
 
 removeAll ()
 
 getSize ($released=false)
 
 getForgottenItemsReport ()
 
 _trackCaller ($itemid, $rc_diff)
 
 getAssetKeys ()
 
- Public Member Functions inherited from MySource_Object
 MySource_Object ()
 
 __sleep ()
 
 __wakeup ()
 

Data Fields

 $_items = Array()
 
 $_items_released = Array()
 
 $_size_rules
 
- Data Fields inherited from MySource_Object
 $_tmp
 

Detailed Description

Definition at line 42 of file asset_cache.inc.

Member Function Documentation

_applySizeRules ( )

Applies the size rules, if the current cache size exceeds the rules an item will be removed.

Returns
void private

Definition at line 218 of file asset_cache.inc.

_trackCaller (   $itemid,
  $rc_diff 
)

Add information in the cache about the caller class

Parameters
string$itemidid of the item which RC has changed
int$rc_diffdifference in the reference count (eg. +1, -1)
Returns
void private

Definition at line 338 of file asset_cache.inc.

add (   $item,
  $itemid = -1 
)

Adds an item in the cache Sets the ref count of the item to 1.

Parameters
object$itemthe item to add
string$itemidthe item id (if -1, the id is determined by $item->id)
Returns
boolean false if the item is already in the cache public

Definition at line 119 of file asset_cache.inc.

Constructor

Returns
Asset_Cache public

Definition at line 82 of file asset_cache.inc.

get (   $itemid)

Fetch an item from the cache Returns a reference to this item (null if not found)

Parameters
string$itemidthe id of the item to get
Returns
object public

Definition at line 152 of file asset_cache.inc.

getAssetKeys ( )

Returns all item ids currently loaded in asset cache

Returns
array public

Definition at line 374 of file asset_cache.inc.

getForgottenItemsReport ( )

Returns a information string about all the assets in the cache which Ref Count > 0

Returns
string public

Definition at line 301 of file asset_cache.inc.

getSize (   $released = false)

Returns the number of items in the cache.

Parameters
boolean$releasedif true only returns the number of released items if false returns the total number of items
Returns
int public

Definition at line 287 of file asset_cache.inc.

release (   $itemid)

Release an item from the cache. Practicaly, it just decreases the RC of the item, if the RC drops to 0 it may be removed from the cache.

Parameters
string$itemidthe id of the item to release
Returns
boolean false if the item is not in the cache or its RC = 0 public

Definition at line 187 of file asset_cache.inc.

remove (   $itemid,
  $force = false 
)

Remove an item from the cache The item must have a RC = 0

Parameters
string$itemidid of the item to remove
boolean$forceif true, the asset is removed even if its RC is > 0, this option shouldn't be used, it is there to remain compatible with the old code.
Returns
boolean false if the item is not in the cache or RC > 0 public

Definition at line 248 of file asset_cache.inc.

removeAll ( )

Remove all released items from the cache

Returns
void public

Definition at line 268 of file asset_cache.inc.

setSizeRules (   $size = -1,
  $all_items = false 
)

Sets the size rules

Parameters
int$sizemaximum allowed number of items if-1,items will never be automatically removed from the cache
int$all_itemsif true, the rule applies to all the assets in the cache, otherwise it applies only to the released assets.
Returns
void public

Definition at line 100 of file asset_cache.inc.


The documentation for this class was generated from the following file: