-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
94 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2021 Upstash, Inc. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,87 @@ | ||
<!-- | ||
This README describes the package. If you publish this package to pub.dev, | ||
this README's contents appear on the landing page for your package. | ||
# Upstash Redis | ||
|
||
For information about how to write a good package README, see the guide for | ||
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages). | ||
`@upstash/redis` is an HTTP/REST based Redis client for dart, built on top | ||
of [Upstash REST API](https://docs.upstash.com/features/restapi). | ||
|
||
For general information about developing packages, see the Dart guide for | ||
[creating packages](https://dart.dev/guides/libraries/create-library-packages) | ||
and the Flutter guide for | ||
[developing packages and plugins](https://flutter.dev/developing-packages). | ||
--> | ||
This Dart package mirrors the design of official upstash-redis typescript library. Find the documentation [here](https://github.com/upstash/upstash-redis). | ||
|
||
TODO: Put a short description of the package here that helps potential users | ||
know whether this package might be useful for them. | ||
It is the only connectionless (HTTP based) Redis client and designed for: | ||
|
||
## Features | ||
- Serverless functions (AWS Lambda ...) | ||
- Cloudflare Workers | ||
- Fastly Compute@Edge | ||
- Client side web/mobile applications | ||
- WebAssembly | ||
- and other environments where HTTP is preferred over TCP. | ||
|
||
TODO: List what your package can do. Maybe include images, gifs, or videos. | ||
See | ||
[the list of APIs](https://docs.upstash.com/features/restapi#rest---redis-api-compatibility) | ||
supported. | ||
|
||
## Getting started | ||
## Quick Start | ||
|
||
TODO: List prerequisites and provide or point to information on how to | ||
start using the package. | ||
### Install | ||
|
||
## Usage | ||
```bash | ||
dart pub add upstash_redis | ||
``` | ||
|
||
### Create database | ||
|
||
TODO: Include short and useful examples for package users. Add longer examples | ||
to `/example` folder. | ||
Create a new redis database on [upstash](https://console.upstash.com/) | ||
|
||
## Basic Usage: | ||
|
||
```dart | ||
const like = 'sample'; | ||
import 'package:upstash_redis/upstash_redis.dart'; | ||
void main() async { | ||
const redis = new Redis( | ||
url: '<UPSTASH_REDIS_REST_URL>', | ||
token: '<UPSTASH_REDIS_REST_TOKEN>', | ||
); | ||
// string | ||
await redis.set('key', 'value'); | ||
final value1 = await redis.get('key'); | ||
print(value1); | ||
await redis.set('key2', 'value2', ex: 1); | ||
// sorted set | ||
await redis.zadd('scores', score: 1, member: 'team1'); | ||
final value2 = await redis.zrange('scores', 0, 100); | ||
print(value1); | ||
// list | ||
await redis.lpush('elements', ['magnesium']); | ||
final value3 = await redis.lrange('elements', 0, 100); | ||
print(value3); | ||
// hash | ||
await redis.hset('people', {'name': 'joe'}); | ||
final value4 = await redis.hget('people', 'name'); | ||
print(value4); | ||
// sets | ||
await redis.sadd('animals', ['cat']); | ||
final value5 = await redis.spop<String>('animals', 1); | ||
print(value5); | ||
} | ||
``` | ||
|
||
## Additional information | ||
## Contributing | ||
|
||
- Fork the repo on [GitHub](https://github.com/rebaz94/upstash-redis) | ||
- Clone the project to your own machine | ||
- Commit changes to your own branch | ||
- Push your work back up to your fork | ||
- Submit a Pull request so that we can review your changes and merge | ||
|
||
## License | ||
|
||
This repo is licenced under MIT. | ||
|
||
## Credits | ||
|
||
TODO: Tell users more about the package: where to find more information, how to | ||
contribute to the package, how to file issues, what response they can expect | ||
from the package authors, and more. | ||
- https://github.com/upstash/upstash-redis/ |