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