Apache Zeta Components Manual :: File Source for replacement_strategy.php

Source for file replacement_strategy.php

Documentation is available at replacement_strategy.php

  1. <?php
  2. /**
  3.  * File containing the ezcCacheStackReplacementStrategy interface.
  4.  *
  5.  * Licensed to the Apache Software Foundation (ASF) under one
  6.  * or more contributor license agreements.  See the NOTICE file
  7.  * distributed with this work for additional information
  8.  * regarding copyright ownership.  The ASF licenses this file
  9.  * to you under the Apache License, Version 2.0 (the
  10.  * "License"); you may not use this file except in compliance
  11.  * with the License.  You may obtain a copy of the License at
  12.  * 
  13.  *   http://www.apache.org/licenses/LICENSE-2.0
  14.  * 
  15.  * Unless required by applicable law or agreed to in writing,
  16.  * software distributed under the License is distributed on an
  17.  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18.  * KIND, either express or implied.  See the License for the
  19.  * specific language governing permissions and limitations
  20.  * under the License.
  21.  *
  22.  * @package Cache
  23.  * @version //autogentag//
  24.  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  25.  * @filesource
  26.  */
  27.  
  28. /**
  29.  * Interface to be implemented by stack replacement strategies.
  30.  *
  31.  * This interface is to be implemented by replacement strategy classes, which
  32.  * can be configured to be used by an {@link ezcCacheStack}. The defined
  33.  * methods wrap around their counterparts on {@link ezcCacheStackableStorage}.
  34.  *
  35.  * A replacement strategy must take care about the actual
  36.  * storing/restoring/deleting of cache items in the given storage. In addition
  37.  * it must take care about keeping the needed {@link ezcCacheStackMetaData} up
  38.  * to date and about purging data from the cache storage, if it runs full.
  39.  *
  40.  * A replacement strategy must define its own meta data class which implements
  41.  * {@link ezcCacheStackMetaData}. It must check in each method call, that the
  42.  * given $metaData is of correct type. If this is not the case, {@link }
  43.  * ezcCacheInvalidMetaDataException} must be throwen.
  44.  * 
  45.  * @package Cache
  46.  * @version //autogentag//
  47.  */
  48. {
  49.     /**
  50.      * Stores the given $itemData in the storage given in $conf.
  51.      *
  52.      * This method stores the given $itemData assigned to $itemId and
  53.      * optionally $itemAttributes in the {@link ezcCacheStackableStorage} given
  54.      * in $conf. In case the storage has reached the $itemLimit defined in
  55.      * $conf, it must be freed according to $freeRate {@link }
  56.      * ezcCacheStackStorageConfiguration}.
  57.      *
  58.      * The freeing of items from the storage must first happen via {@link }
  59.      * ezcCacheStackableStorage::purge()}, which removes outdated items from
  60.      * the storage and returns the affected IDs. In case this does not last to
  61.      * free the desired number of items, the replacement strategy specific
  62.      * algorithm for freeing takes effect.
  63.      *
  64.      * After the necessary freeing process has been performed, the item is
  65.      * stored in the storage and the $metaData is updated accordingly.
  66.      *
  67.      * @param ezcCacheStackStorageConfiguration $conf 
  68.      * @param ezcCacheStackMetaData $metaData 
  69.      * @param string $itemId 
  70.      * @param mixed $itemData 
  71.      * @param array(string=>string) $itemAttributes 
  72.      * @throws ezcCacheInvalidMetaDataException
  73.      *          if the given $metaData is not processable by this replacement
  74.      *          strategy.
  75.      */
  76.     public static function store(
  77.         ezcCacheStackStorageConfiguration $conf,
  78.         ezcCacheStackMetaData $metaData,
  79.         $itemId,
  80.         $itemData,
  81.         $itemAttributes array()
  82.     );
  83.  
  84.     /**
  85.      * Restores the data with the given $dataId from the storage given in $conf.
  86.      *
  87.      * This method takes care of restoring the item with ID $itemId and
  88.      * optionally $itemAttributes from the {@link ezcCacheStackableStorage}
  89.      * given in $conf. The parameters $itemId, $itemAttributes and $search are
  90.      * forwarded to {@link ezcCacheStackableStorage::restore()}, the returned
  91.      * value (item data on successful restore, otherwise false) are returned by
  92.      * this method.
  93.      *
  94.      * The method must take care that the restore process is reflected in
  95.      * $metaData according to the spcific replacement strategy implementation.
  96.      *
  97.      * @param ezcCacheStackStorageConfiguration $conf 
  98.      * @param ezcCacheStackMetaData $metaData 
  99.      * @param string $itemId 
  100.      * @param array(string=>string) $itemAttributes 
  101.      * @param bool $search 
  102.      *
  103.      * @return mixed Restored data or false.
  104.      * @throws ezcCacheInvalidMetaDataException
  105.      *          if the given $metaData is not processable by this replacement
  106.      *          strategy.
  107.      */
  108.     public static function restore(
  109.         ezcCacheStackStorageConfiguration $conf,
  110.         ezcCacheStackMetaData $metaData,
  111.         $itemId,
  112.         $itemAttributes array(),
  113.         $search false
  114.     );
  115.  
  116.     /**
  117.      * Deletes the data with the given $itemId from the given $storage.
  118.      *
  119.      * This method takes care about deleting the item identified by $itemId and
  120.      * optionally $itemAttributes from the {@link ezcCacheStackableStorage}
  121.      * give in $conf. The parameters $itemId, $itemAttributes and $search are
  122.      * therefore forwarded to {@link ezcCacheStackableStorage::delete()}. This
  123.      * method returns a list of all item IDs that have been deleted by the
  124.      * call. The method reflects these changes in $metaData.
  125.      *
  126.      * @param ezcCacheStackStorageConfiguration $conf 
  127.      * @param ezcCacheStackMetaData $metaData 
  128.      * @param string $itemId 
  129.      * @param array(string=>string) $itemAttributes 
  130.      * @param bool $search 
  131.      *
  132.      * @return array(string) Deleted item IDs.
  133.      * @throws ezcCacheInvalidMetaDataException
  134.      *          if the given $metaData is not processable by this replacement
  135.      *          strategy.
  136.      */
  137.     public static function delete(
  138.         ezcCacheStackStorageConfiguration $conf,
  139.         ezcCacheStackMetaData $metaData,
  140.         $itemId,
  141.         $itemAttributes array(),
  142.         $search false
  143.     );
  144.  
  145.     /**
  146.      * Returns a fresh meta data object.
  147.      *
  148.      * Different replacement strategies will use different meta data classes.
  149.      * This method must return a freshly created instance of the meta data
  150.      * object used by this meta data.
  151.      * 
  152.      * @return ezcCacheStackMetaData 
  153.      */
  154.     public static function createMetaData();
  155. }
  156.  
  157. ?>
Documentation generated by phpDocumentor 1.4.3