KeyCache.php 2.8KB

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