KeyCache.php 2.9KB

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