KeyCache.php 2.5KB

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