-
Notifications
You must be signed in to change notification settings - Fork 528
PersistentCacheStore & In Memory Blocking Cache
PersistentCacheStore
is the team's replacement to SharedPreferences
except it:
- Never blocks the main thread
- Forces using protocol buffers for the underlying storage structure to encourage background & forward compatibility
- Is a
DataProvider
which means it can be easily interoped with the codebase's otherDataProvider
s
Note as of 8 April 2021: PersistentCacheStore
was created before DataStore
from Android Jetpack was available for production use. The team may eventually migrate to this solution, but it's not currently planned.
While not a DataProvider
, InMemoryBlockingCache
is a concurrency primitive the team built to ensure single-threaded access to a single variable in-memory where the cache itself can be safely accessed from multiple threads, and no locking mechanism is needed. This is a coroutine-only utility that is meant to improve cross-thread state sharing performance, and is generally only used in cases where state must be synchronized across multiple threads.
There are other cases of background processing and concurrency that come up on the team, but don't yet have established best practices. One such example is triggering logic from Android's work manager (example: FirebaseLogUploader
). Note that while these approaches aren't fully documented yet, the same best practices & principles above should be observed and enforced to ensure a good experience is provided both to end users and developers maintaining the app.
Have an idea for how to improve the wiki? Please help make our documentation better by following our instructions for contributing to the wiki.
Core documentation
Developing Oppia
- Contributing to Oppia Android
- Bazel
- Key Workflows
- Testing
- Developing Skills
- Frequent Errors and Solutions
- RTL Guidelines
- Working on UI
- Writing Design Docs
Developer Reference
- Code style
- Background Processing
- Dark mode
- Buf Guide
- Firebase Console Guide
- Platform Parameters & Feature Flags
- Work Manager
- Dependency Injection with Dagger
- Revert & regression policy
- Upgrading target SDK version
- Spotlight Guide
- Triaging Process
- Bazel
- Internationalization
- Terminology in Oppia
- Past Events