From 5906ec536cdf4e5661eac21bb4e71c75c7d16b78 Mon Sep 17 00:00:00 2001 From: Hamdal Date: Sat, 14 Mar 2026 15:42:18 +0100 Subject: [PATCH] add license, readme --- LICENSE | 21 +++++++++++++++ README.md | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ec36c2d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Hameed Abdullateef + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..8338b7c --- /dev/null +++ b/README.md @@ -0,0 +1,78 @@ +# Syncache + +An offline-first cache and sync engine for Dart and Flutter applications. + +## Packages + +| Package | Description | pub.dev | +|---------|-------------|---------| +| [syncache](packages/syncache) | Core caching library for Dart | [![pub package](https://img.shields.io/pub/v/syncache.svg)](https://pub.dev/packages/syncache) | +| [syncache_flutter](packages/syncache_flutter) | Flutter integration with widgets and lifecycle management | [![pub package](https://img.shields.io/pub/v/syncache_flutter.svg)](https://pub.dev/packages/syncache_flutter) | + +## Features + +- **Multiple caching policies** - offlineFirst, cacheOnly, networkOnly, refresh, staleWhileRefresh +- **Reactive streams** - Subscribe to cache updates with `watch()` +- **Optimistic mutations** - Update UI immediately while syncing in background +- **Tag-based invalidation** - Group and invalidate related cache entries +- **Flutter integration** - Widgets, lifecycle management, connectivity detection + +## Quick Start + +### Dart + +```yaml +dependencies: + syncache: ^0.1.0 +``` + +```dart +import 'package:syncache/syncache.dart'; + +final cache = Syncache(store: MemoryStore()); + +// Fetch with offline-first policy +final user = await cache.get( + key: 'user:123', + fetch: (request) => api.getUser(123), +); +``` + +### Flutter + +```yaml +dependencies: + syncache: ^0.1.0 + syncache_flutter: ^0.1.0 +``` + +```dart +import 'package:syncache/syncache.dart'; +import 'package:syncache_flutter/syncache_flutter.dart'; + +// Provide cache to widget tree +SyncacheScope( + cache: userCache, + network: FlutterNetwork(), + child: MyApp(), +) + +// Display cached data reactively +CacheBuilder( + cacheKey: 'user:123', + fetch: (request) => api.getUser(123), + builder: (context, snapshot) { + if (!snapshot.hasData) return CircularProgressIndicator(); + return Text(snapshot.data!.name); + }, +) +``` + +## Documentation + +- [syncache documentation](packages/syncache/README.md) +- [syncache_flutter documentation](packages/syncache_flutter/README.md) + +## License + +MIT License - see [LICENSE](LICENSE) for details.