4 * This file is part of SwiftMailer.
5 * (c) 2004-2009 Chris Corbyn
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 //@require 'Swift/InputByteStream.php';
12 //@require 'Swift/OutputByteStream.php';
15 * Provides a mechanism for storing data using two keys.
17 * @subpackage KeyCache
18 * @author Chris Corbyn
20 interface Swift_KeyCache
23 /** Mode for replacing existing cached data */
26 /** Mode for appending data to the end of existing cached data */
27 const MODE_APPEND
= 2;
30 * Set a string into the cache under $itemKey for the namespace $nsKey.
31 * @param string $nsKey
32 * @param string $itemKey
33 * @param string $string
35 * @see MODE_WRITE, MODE_APPEND
37 public function setString($nsKey, $itemKey, $string, $mode);
40 * Set a ByteStream into the cache under $itemKey for the namespace $nsKey.
41 * @param string $nsKey
42 * @param string $itemKey
43 * @param Swift_OutputByteStream $os
45 * @see MODE_WRITE, MODE_APPEND
47 public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream
$os,
51 * Provides a ByteStream which when written to, writes data to $itemKey.
52 * NOTE: The stream will always write in append mode.
53 * If the optional third parameter is passed all writes will go through $is.
54 * @param string $nsKey
55 * @param string $itemKey
56 * @param Swift_InputByteStream $is, optional
57 * @return Swift_InputByteStream
59 public function getInputByteStream($nsKey, $itemKey,
60 Swift_InputByteStream
$is = null);
63 * Get data back out of the cache as a string.
64 * @param string $nsKey
65 * @param string $itemKey
68 public function getString($nsKey, $itemKey);
71 * Get data back out of the cache as a ByteStream.
72 * @param string $nsKey
73 * @param string $itemKey
74 * @param Swift_InputByteStream $is to write the data to
76 public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream
$is);
79 * Check if the given $itemKey exists in the namespace $nsKey.
80 * @param string $nsKey
81 * @param string $itemKey
84 public function hasKey($nsKey, $itemKey);
87 * Clear data for $itemKey in the namespace $nsKey if it exists.
88 * @param string $nsKey
89 * @param string $itemKey
91 public function clearKey($nsKey, $itemKey);
94 * Clear all data in the namespace $nsKey if it exists.
95 * @param string $nsKey
97 public function clearAll($nsKey);