storagemanager.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * EliasDB
  3. *
  4. * Copyright 2016 Matthias Ladkau. All rights reserved.
  5. *
  6. * This Source Code Form is subject to the terms of the Mozilla Public
  7. * License, v. 2.0. If a copy of the MPL was not distributed with this
  8. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. */
  10. package storage
  11. /*
  12. RootIDVersion is the root id holding the version.
  13. */
  14. const RootIDVersion = 1
  15. /*
  16. Manager describes an abstract storage manager.
  17. */
  18. type Manager interface {
  19. /*
  20. Name returns the name of the StorageManager instance.
  21. */
  22. Name() string
  23. /*
  24. Root returns a root value.
  25. */
  26. Root(root int) uint64
  27. /*
  28. SetRoot writes a root value.
  29. */
  30. SetRoot(root int, val uint64)
  31. /*
  32. Insert inserts an object and return its storage location.
  33. */
  34. Insert(o interface{}) (uint64, error)
  35. /*
  36. Update updates a storage location.
  37. */
  38. Update(loc uint64, o interface{}) error
  39. /*
  40. Free frees a storage location.
  41. */
  42. Free(loc uint64) error
  43. /*
  44. Fetch fetches an object from a given storage location and writes it to
  45. a given data container.
  46. */
  47. Fetch(loc uint64, o interface{}) error
  48. /*
  49. FetchCached fetches an object from a cache and returns its reference.
  50. Returns a storage.ErrNotInCache error if the entry is not in the cache.
  51. */
  52. FetchCached(loc uint64) (interface{}, error)
  53. /*
  54. Flush writes all pending changes to disk.
  55. */
  56. Flush() error
  57. /*
  58. Rollback cancels all pending changes which have not yet been written to disk.
  59. */
  60. Rollback() error
  61. /*
  62. Close the StorageManager and write all pending changes to disk.
  63. */
  64. Close() error
  65. }