tree: 4bdf52b04e6bef1136d5441d01b21762f92ec535 [path history] [tgz]
  1. mock/
  2. sqlite/
  3. backend.cc
  4. backend.h
  5. backend_params.cc
  6. backend_params.h
  7. backend_params_manager.cc
  8. backend_params_manager.h
  9. backend_params_manager_unittest.cc
  10. BUILD.gn
  11. DEPS
  12. entry.cc
  13. entry.h
  14. entry_metadata.h
  15. entry_unittest.cc
  16. OWNERS
  17. persistent_cache.cc
  18. persistent_cache.h
  19. persistent_cache_collection.cc
  20. persistent_cache_collection.h
  21. persistent_cache_collection_unittest.cc
  22. persistent_cache_fuchsia.cc
  23. persistent_cache_perftest.cc
  24. persistent_cache_unittest.cc
  25. README.md
components/persistent_cache/README.md

Persistent Cache

Persistent cache provides an API to store and retrieve key-value pairs in files. It is serverless; any process/thread with access to the files can open them via the persistent cache API and use it to store/retrieve entries. Concurrency is managed internally by persistent cache. Entries stored in a persistent cache may be evicted at any point, so it's incorrect to assume that an entry that was just stored in the cache can be retrieved.

The usage pattern targeted by persistent_cache is kept simple on purpose to allow for flexibility of implementation in the backends. Clients should expect to be able to store and retrieve values but cannot rely on any other behavior.

Success guarantees

persistent_cache represents at its core a best-effort mechanism. It's impossible to guarantee an entry was inserted since the backing could run out of space. Instead of treating this occurrence like an out-of-memory exception and crashing the classes in this file rely on the contracts described by their APIs to guide user code into running the appropriate checks.

Security

While persistent_cache is agnostic to Chrome's security model some of its design decisions are made to comform to it.

File access.

  • Backends have to be able to function being provided only base::File instances and not paths.
  • Backends cannot rely on the ability to create or delete files.
  • Backends have to be functional even with read-only access to files.

Eviction

To retain simplicity of design persistent_cache does not expose or enforce eviction mechanisms. Clients of the cache can assume that they are free to insert as many entries are desired without having to reason about size management.