|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of SwiftMailer. |
|
5 * (c) 2004-2009 Chris Corbyn |
|
6 * |
|
7 * For the full copyright and license information, please view the LICENSE |
|
8 * file that was distributed with this source code. |
|
9 */ |
|
10 |
|
11 |
|
12 /** |
|
13 * Provides a mechanism for storing data using two keys. |
|
14 * @package Swift |
|
15 * @subpackage KeyCache |
|
16 * @author Chris Corbyn |
|
17 */ |
|
18 interface Swift_KeyCache |
|
19 { |
|
20 |
|
21 /** Mode for replacing existing cached data */ |
|
22 const MODE_WRITE = 1; |
|
23 |
|
24 /** Mode for appending data to the end of existing cached data */ |
|
25 const MODE_APPEND = 2; |
|
26 |
|
27 /** |
|
28 * Set a string into the cache under $itemKey for the namespace $nsKey. |
|
29 * @param string $nsKey |
|
30 * @param string $itemKey |
|
31 * @param string $string |
|
32 * @param int $mode |
|
33 * @see MODE_WRITE, MODE_APPEND |
|
34 */ |
|
35 public function setString($nsKey, $itemKey, $string, $mode); |
|
36 |
|
37 /** |
|
38 * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. |
|
39 * @param string $nsKey |
|
40 * @param string $itemKey |
|
41 * @param Swift_OutputByteStream $os |
|
42 * @param int $mode |
|
43 * @see MODE_WRITE, MODE_APPEND |
|
44 */ |
|
45 public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, |
|
46 $mode); |
|
47 |
|
48 /** |
|
49 * Provides a ByteStream which when written to, writes data to $itemKey. |
|
50 * NOTE: The stream will always write in append mode. |
|
51 * If the optional third parameter is passed all writes will go through $is. |
|
52 * @param string $nsKey |
|
53 * @param string $itemKey |
|
54 * @param Swift_InputByteStream $is, optional |
|
55 * @return Swift_InputByteStream |
|
56 */ |
|
57 public function getInputByteStream($nsKey, $itemKey, |
|
58 Swift_InputByteStream $is = null); |
|
59 |
|
60 /** |
|
61 * Get data back out of the cache as a string. |
|
62 * @param string $nsKey |
|
63 * @param string $itemKey |
|
64 * @return string |
|
65 */ |
|
66 public function getString($nsKey, $itemKey); |
|
67 |
|
68 /** |
|
69 * Get data back out of the cache as a ByteStream. |
|
70 * @param string $nsKey |
|
71 * @param string $itemKey |
|
72 * @param Swift_InputByteStream $is to write the data to |
|
73 */ |
|
74 public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is); |
|
75 |
|
76 /** |
|
77 * Check if the given $itemKey exists in the namespace $nsKey. |
|
78 * @param string $nsKey |
|
79 * @param string $itemKey |
|
80 * @return boolean |
|
81 */ |
|
82 public function hasKey($nsKey, $itemKey); |
|
83 |
|
84 /** |
|
85 * Clear data for $itemKey in the namespace $nsKey if it exists. |
|
86 * @param string $nsKey |
|
87 * @param string $itemKey |
|
88 */ |
|
89 public function clearKey($nsKey, $itemKey); |
|
90 |
|
91 /** |
|
92 * Clear all data in the namespace $nsKey if it exists. |
|
93 * @param string $nsKey |
|
94 */ |
|
95 public function clearAll($nsKey); |
|
96 |
|
97 } |