KeyCache.php 2.8 KB

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