一键导入
authoring-local-source
Authoring a new local source allows different storage mechanisms to participate in the data layer caching architecture.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Authoring a new local source allows different storage mechanisms to participate in the data layer caching architecture.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Understand how sources declare operation capabilities via supportedOperations and how SourceList respects them.
FirestoreAdminSource connects google_cloud_firestore for server-side Dart applications to a SourceList.
FirestoreSource seamlessly connects Cloud Firestore streams to a SourceList.
Perform untyped Firestore document merges using the raw method on Firestore sources.
Cached data is mapped uniquely per request hash (RequestDetails with specific filter and pagination), supporting a powerful request-based caching behavior.
The SourceList class manages the delegation of read/write attempts to various configured Sources, with a read-thru cache system prioritizing local Sources.
| name | authoring-local-source |
| description | Authoring a new local source allows different storage mechanisms to participate in the data layer caching architecture. |
| metadata | {"last_modified":"Sat, 18 Apr 2026 1:52:50 GMT"} |
Authoring a new type of LocalSource is appropriate when you require a different storage mechanism from any existing LocalSource subclass or implementation. In such a scenario, the true task will ultimately amount to writing new SourceCache classes which bind to this required storage mechanism.
LocalSource itself is fully flexible and ready for varied use in any case, so custom implementations can either use fresh SourceCache implementations which must then be correctly passed to the generic LocalSource.new constructor, can use the convenience LocalSource.builders constructor, or can hide these details in a subclass.
The two existing LocalSource implementations offered by the library LocalMemorySource and HiveSource (the latter of which comes from pkg:data_layer_hive.)
The LocalMemorySource class and its workhorse, InMemoryPersistence, highlight the dedicated-class way to implement a source.
class MySourceCache<T> extends SourceCache<T> {
// ... implementations which make no assumptions about what T is
}
final myLocalSource = LocalSource.builders<T>(
itemCache: (String name) => MySourceCache<T>(),
setStringCache: (String name) => MySourceCache<Set<String>>(),
dateTimeCache: (String name) => MySourceCache<DateTime>(),
);
If necessary, you can use the provided name parameter to differentiate between the returned instances of MySourceCache. This can be important, depending on your actual persistence mechanism and whether it requires unique namespaces (like Hive, which requires unique box names). The above example does not use this name parameter, but if the implementation of MySourceCache required a unique namespace then this sample would be adapted to pass name to each constructor invocation.