TYPO3 API  SVNRelease
KeyCache.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  * This file is part of SwiftMailer.
00005  * (c) 2004-2009 Chris Corbyn
00006  *
00007  * For the full copyright and license information, please view the LICENSE
00008  * file that was distributed with this source code.
00009  */
00010 
00011 //@require 'Swift/InputByteStream.php';
00012 //@require 'Swift/OutputByteStream.php';
00013 
00014 /**
00015  * Provides a mechanism for storing data using two keys.
00016  * @package Swift
00017  * @subpackage KeyCache
00018  * @author Chris Corbyn
00019  */
00020 interface Swift_KeyCache
00021 {
00022 
00023   /** Mode for replacing existing cached data */
00024   const MODE_WRITE = 1;
00025 
00026   /** Mode for appending data to the end of existing cached data */
00027   const MODE_APPEND = 2;
00028 
00029   /**
00030    * Set a string into the cache under $itemKey for the namespace $nsKey.
00031    * @param string $nsKey
00032    * @param string $itemKey
00033    * @param string $string
00034    * @param int $mode
00035    * @see MODE_WRITE, MODE_APPEND
00036    */
00037   public function setString($nsKey, $itemKey, $string, $mode);
00038 
00039   /**
00040    * Set a ByteStream into the cache under $itemKey for the namespace $nsKey.
00041    * @param string $nsKey
00042    * @param string $itemKey
00043    * @param Swift_OutputByteStream $os
00044    * @param int $mode
00045    * @see MODE_WRITE, MODE_APPEND
00046    */
00047   public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os,
00048     $mode);
00049 
00050   /**
00051    * Provides a ByteStream which when written to, writes data to $itemKey.
00052    * NOTE: The stream will always write in append mode.
00053    * If the optional third parameter is passed all writes will go through $is.
00054    * @param string $nsKey
00055    * @param string $itemKey
00056    * @param Swift_InputByteStream $is, optional
00057    * @return Swift_InputByteStream
00058    */
00059   public function getInputByteStream($nsKey, $itemKey,
00060     Swift_InputByteStream $is = null);
00061 
00062   /**
00063    * Get data back out of the cache as a string.
00064    * @param string $nsKey
00065    * @param string $itemKey
00066    * @return string
00067    */
00068   public function getString($nsKey, $itemKey);
00069 
00070   /**
00071    * Get data back out of the cache as a ByteStream.
00072    * @param string $nsKey
00073    * @param string $itemKey
00074    * @param Swift_InputByteStream $is to write the data to
00075    */
00076   public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is);
00077 
00078   /**
00079    * Check if the given $itemKey exists in the namespace $nsKey.
00080    * @param string $nsKey
00081    * @param string $itemKey
00082    * @return boolean
00083    */
00084   public function hasKey($nsKey, $itemKey);
00085 
00086   /**
00087    * Clear data for $itemKey in the namespace $nsKey if it exists.
00088    * @param string $nsKey
00089    * @param string $itemKey
00090    */
00091   public function clearKey($nsKey, $itemKey);
00092 
00093   /**
00094    * Clear all data in the namespace $nsKey if it exists.
00095    * @param string $nsKey
00096    */
00097   public function clearAll($nsKey);
00098 
00099 }