KeyCache.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 int $mode
  39. */
  40. public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode);
  41. /**
  42. * Provides a ByteStream which when written to, writes data to $itemKey.
  43. *
  44. * NOTE: The stream will always write in append mode.
  45. * If the optional third parameter is passed all writes will go through $is.
  46. *
  47. * @param string $nsKey
  48. * @param string $itemKey
  49. * @param Swift_InputByteStream $is optional input stream
  50. *
  51. * @return Swift_InputByteStream
  52. */
  53. public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $is = null);
  54. /**
  55. * Get data back out of the cache as a string.
  56. *
  57. * @param string $nsKey
  58. * @param string $itemKey
  59. *
  60. * @return string
  61. */
  62. public function getString($nsKey, $itemKey);
  63. /**
  64. * Get data back out of the cache as a ByteStream.
  65. *
  66. * @param string $nsKey
  67. * @param string $itemKey
  68. * @param Swift_InputByteStream $is stream to write the data to
  69. */
  70. public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is);
  71. /**
  72. * Check if the given $itemKey exists in the namespace $nsKey.
  73. *
  74. * @param string $nsKey
  75. * @param string $itemKey
  76. *
  77. * @return bool
  78. */
  79. public function hasKey($nsKey, $itemKey);
  80. /**
  81. * Clear data for $itemKey in the namespace $nsKey if it exists.
  82. *
  83. * @param string $nsKey
  84. * @param string $itemKey
  85. */
  86. public function clearKey($nsKey, $itemKey);
  87. /**
  88. * Clear all data in the namespace $nsKey if it exists.
  89. *
  90. * @param string $nsKey
  91. */
  92. public function clearAll($nsKey);
  93. }