Published angel3_redis
This commit is contained in:
parent
1a63e8f6bd
commit
92df34f375
6 changed files with 36 additions and 27 deletions
packages/redis
|
@ -1,5 +1,9 @@
|
||||||
# 2.0.0
|
# Change Log
|
||||||
|
|
||||||
|
## 2.0.0
|
||||||
|
|
||||||
* Migrated to support Dart SDK 2.12.x NNBD
|
* Migrated to support Dart SDK 2.12.x NNBD
|
||||||
|
|
||||||
# 1.0.0
|
## 1.0.0
|
||||||
* First version.
|
|
||||||
|
* First version.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2018 The Angel Framework
|
Copyright (c) 2021 dukefirehawk.com
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -1,54 +1,59 @@
|
||||||
# redis
|
# Angel3 Redis
|
||||||
[](https://pub.dartlang.org/packages/angel_redis)
|
|
||||||
[](https://travis-ci.org/angel-dart/redis)
|
|
||||||
|
|
||||||
Redis-enabled services for the Angel framework.
|
[](https://pub.dartlang.org/packages/angel3_redis)
|
||||||
`RedisService` can be used alone, *or* as the backend of a
|
[](https://dart.dev/null-safety)
|
||||||
[`CacheService`](https://github.com/angel-dart/cache),
|
[](https://gitter.im/angel_dart/discussion)
|
||||||
and thereby cache the results of calling an upstream database.
|
|
||||||
|
[](https://github.com/dukefirehawk/angel/tree/angel3/packages/redis/LICENSE)
|
||||||
|
|
||||||
|
**Forked from `angel_redis` to support NNBD**
|
||||||
|
|
||||||
|
Redis-enabled services for the Angel3 framework. `RedisService` can be used alone, *or* as the backend of a [`CacheService`](https://pub.dev/packages/angel3_cache), and thereby cache the results of calling an upstream database.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
`package:angel_redis` requires Angel 2.
|
|
||||||
|
`package:angel3_redis` requires Angel3.
|
||||||
|
|
||||||
In your `pubspec.yaml`:
|
In your `pubspec.yaml`:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
dependencies:
|
dependencies:
|
||||||
angel_framework: ^2.0.0-alpha
|
angel3_framework: ^4.0.0
|
||||||
angel_redis: ^1.0.0
|
angel3_redis: ^2.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
Pass an instance of `RespCommands` (from `package:resp_client`) to the `RedisService` constructor.
|
|
||||||
You can also pass an optional prefix, which is recommended if you are using `angel_redis` for multiple
|
Pass an instance of `RespCommandsTier2` (from `package:resp_client`) to the `RedisService` constructor. You can also pass an optional prefix, which is recommended if you are using `angel3_redis` for multiple logically-separate collections. Redis is a flat key-value store; by prefixing the keys used, `angel3_redis` can provide the experience of using separate stores, rather than a single node.
|
||||||
logically-separate collections. Redis is a flat key-value store; by prefixing the keys used,
|
|
||||||
`angel_redis` can provide the experience of using separate stores, rather than a single node.
|
|
||||||
|
|
||||||
Without a prefix, there's a chance that different collections can overwrite one another's data.
|
Without a prefix, there's a chance that different collections can overwrite one another's data.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
* Neither `index`, nor `modify` is atomic; each performs two separate queries.`angel_redis` stores data as JSON strings, rather than as Redis hashes, so an update-in-place is impossible.
|
|
||||||
|
* Neither `index`, nor `modify` is atomic; each performs two separate queries.`angel3_redis` stores data as JSON strings, rather than as Redis hashes, so an update-in-place is impossible.
|
||||||
* `index` uses Redis' `KEYS` functionality, so use it sparingly in production, if at all. In a larger database, it can quickly
|
* `index` uses Redis' `KEYS` functionality, so use it sparingly in production, if at all. In a larger database, it can quickly
|
||||||
become a bottleneck.
|
become a bottleneck.
|
||||||
* `remove` uses `MULTI`+`EXEC` in a transaction.
|
* `remove` uses `MULTI`+`EXEC` in a transaction.
|
||||||
* Prefer using `update`, rather than `modify`. The former only performs one query, though it does overwrite the current
|
* Prefer using `update`, rather than `modify`. The former only performs one query, though it does overwrite the current
|
||||||
contents for a given key.
|
contents for a given key.
|
||||||
* When calling `create`, it's possible that you may already have an `id` in mind to insert into the store. For example,
|
* When calling `create`, it's possible that you may already have an `id` in mind to insert into the store. For example,
|
||||||
when caching another database, you'll preserve the ID or primary key of an item. `angel_redis` heeds this. If no
|
when caching another database, you'll preserve the ID or primary key of an item. `angel3_redis` heeds this. If no
|
||||||
`id` is present, then an ID will be created via an `INCR` call.
|
`id` is present, then an ID will be created via an `INCR` call.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
Also present at `example/main.dart`:
|
Also present at `example/main.dart`:
|
||||||
|
|
||||||
```dart
|
```dart
|
||||||
import 'package:angel_redis/angel_redis.dart';
|
import 'package:angel3_redis/angel3_redis.dart';
|
||||||
import 'package:resp_client/resp_client.dart';
|
import 'package:resp_client/resp_client.dart';
|
||||||
import 'package:resp_client/resp_commands.dart';
|
import 'package:resp_client/resp_commands.dart';
|
||||||
|
import 'package:resp_client/resp_server.dart';
|
||||||
|
|
||||||
main() async {
|
main() async {
|
||||||
var connection = await connectSocket('localhost');
|
var connection = await connectSocket('localhost');
|
||||||
var client = new RespClient(connection);
|
var client = RespClient(connection);
|
||||||
var service = new RedisService(new RespCommands(client), prefix: 'example');
|
var service = RedisService(RespCommandsTier2(client), prefix: 'example');
|
||||||
|
|
||||||
// Create an object
|
// Create an object
|
||||||
await service.create({'id': 'a', 'hello': 'world'});
|
await service.create({'id': 'a', 'hello': 'world'});
|
||||||
|
@ -63,4 +68,4 @@ main() async {
|
||||||
// Close the connection.
|
// Close the connection.
|
||||||
await connection.close();
|
await connection.close();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import 'package:angel_redis/angel_redis.dart';
|
import 'package:angel3_redis/angel3_redis.dart';
|
||||||
import 'package:resp_client/resp_client.dart';
|
import 'package:resp_client/resp_client.dart';
|
||||||
import 'package:resp_client/resp_commands.dart';
|
import 'package:resp_client/resp_commands.dart';
|
||||||
import 'package:resp_client/resp_server.dart';
|
import 'package:resp_client/resp_server.dart';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import 'package:angel_http_exception/angel_http_exception.dart';
|
import 'package:angel_http_exception/angel_http_exception.dart';
|
||||||
import 'package:angel_redis/angel_redis.dart';
|
import 'package:angel3_redis/angel3_redis.dart';
|
||||||
import 'package:resp_client/resp_client.dart';
|
import 'package:resp_client/resp_client.dart';
|
||||||
import 'package:resp_client/resp_commands.dart';
|
import 'package:resp_client/resp_commands.dart';
|
||||||
import 'package:resp_client/resp_server.dart';
|
import 'package:resp_client/resp_server.dart';
|
||||||
|
|
Loading…
Reference in a new issue