A simple and easy to use Redis client for Dart

Overview

redis_dart

A simple and minimalist Redis client for Dart

See it in pub: https://pub.dev/packages/redis_dart
and GitHub: https://github.com/gabrielpacheco23/redis_dart

ko-fi

Usage

import 'package:redis_dart/redis_dart.dart';

void main() async {
  final client = await RedisClient.connect('localhost');

  await client.set('name', 'Gabriel');

  var res = await client.get('name');
  print(res);

  await client.close();
}

Easy to use

This library was meant to be clear and easy to understand, so the methods names are associated to what the function does, like

void main() async {
  final client = await RedisClient.connect('localhost');

  // this is a HSET command
  await client.setMap('info', {
    'name': 'John Doe',
    'email': '[email protected]',
    'age': 34,
  });

  // this one is a HGETALL
  var info = await client.getMap('info');
  print(info);

  await client.close();
}

which returns a Map and then prints

  {name: John Doe, email: [email protected], age: 34}

That way, inserting a Redis Hash is as simple as passing a Dart Map.

API

For full API documentation take a look at https://pub.dev/documentation/redis_dart/latest/

Also, check out the examples directory.

Contribute!

This library still does not covers the full features of Redis, so things like Pub/Sub, Transactions and some commands are not implemented yet, but if you want you can raise a PR to help the library to grow up!

// TODO:

  • Implement all Redis commands
  • Implement Transactions
  • Implement Pub/Sub
  • Maybe some other things

Support my work :)

ko-fi

License

MIT License

Copyright © 2021 Gabriel Pacheco

You might also like...

Notion API client for dart

Notion API client for dart. See the ROADMAP file to see what is coming next. API implemented Usage NotionClient class Individual classes A few example

Oct 9, 2022

Figma API client written in pure Dart

figma A library for interacting with Figma APIs. Created from templates made available by Stagehand under a BSD-style license. Usage A simple usage ex

Oct 19, 2022

A dart client for Supabase Realtime server.

realtime-dart Listens to changes in a PostgreSQL Database and via websockets. A dart client for Supabase Realtime server. Usage Creating a Socket conn

Dec 14, 2022

Expenses tracker built with Flutter and Dart making use of Provider, Intl, Syncfusion Flutter Datepicker and more

expense_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if t

Dec 10, 2022

A beautiful and cross platform NHentai Client, Support desktop and mobile phone

A beautiful and cross platform NHentai Client, Support desktop and mobile phone

A beautiful and cross platform NHentai Client. Support desktop and mobile phone (Mac/Windows/Linux/Android/IOS).

Dec 29, 2022

A Flutter Twitch client for iOS and Android with BTTV, FFZ, and 7TV support

A Flutter Twitch client for iOS and Android with BTTV, FFZ, and 7TV support

Frosty for Twitch A Twitch client for iOS and Android with BTTV, FFZ, and 7TV support. Built with Flutter. Features Browse followed streams, top strea

Jan 5, 2023

Starter architectures for your next Flutter project in order to make it scalable and easy for maintenance and tests.

👷 🔧 🔩 Flutter Starter Architecture (MVVM) My custom starter project for Flutter apps. I was looking for a simple way to build Flutter app in a scal

Dec 25, 2022

A Dart library with a solution to use smart enums

Smart Enums Author: Jop Middelkamp A package that can help you create 'smarter' enums that could be extended with some domain logic. Usage final bestF

Oct 1, 2022
Comments
  • fix: FormatException when setting chinese value

    fix: FormatException when setting chinese value

    When setting a value with special character(like Chinese text. e.g. 中文)

    final redisClient = await RedisClient.connect('localhost');
    redisClient.set('key', '中文');
    

    And it will cause FormatException like this:

    Unhandled exception:
    FormatException: Unexpected extension byte (at offset 27)
    #0      _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1755:7)
    #1      Utf8Decoder.convert (dart:convert/utf.dart:351:42)
    #2      Utf8Codec.decode (dart:convert/utf.dart:63:20)
    #3      respDecoder.<anonymous closure> (package:redis_dart/src/utils/resp_utils.dart:9:60)
    #4      _HandlerEventSink.add (dart:async/stream_transformers.dart:209:17)
    #5      _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
    #6      _RootZone.runUnaryGuarded (dart:async/zone.dart:1618:10)
    #7      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
    #8      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
    #9      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
    #10     _StreamController._add (dart:async/stream_controller.dart:648:7)
    #11     _StreamController.add (dart:async/stream_controller.dart:596:5)
    #12     _Socket._onData (dart:io-patch/socket_patch.dart:2314:41)
    #13     _RootZone.runUnaryGuarded (dart:async/zone.dart:1618:10)
    #14     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
    #15     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
    #16     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
    #17     _StreamController._add (dart:async/stream_controller.dart:648:7)
    #18     _StreamController.add (dart:async/stream_controller.dart:596:5)
    #19     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1839:33)
    #20     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1322:14)
    #21     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
    #22     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
    #23     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:122:13)
    #24     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:193:5)
    

    And just update one line can fix this problem.

    opened by Kent1011 0
  • Cannot send command AUTH after establish connection

    Cannot send command AUTH after establish connection

    final redis = await RedisClient.connect(
        'redishost',
        1234,
      );
    
    await redis.command(
       'AUTH' ['user', 'pass'],
    );
    

    Result

    Unhandled exception:
    Bad state: No elements
    #0      _NextRequest.update (package:async/src/stream_queue.dart:695:70)
    #1      StreamQueue._updateRequests (package:async/src/stream_queue.dart:419:31)
    #2      StreamQueue._close (package:async/src/stream_queue.dart:513:5)
    #3      StreamQueue._ensureListening.<anonymous closure> (package:async/src/stream_queue.dart:481:9)
    #4      _RootZone.runGuarded (dart:async/zone.dart:1534:10)
    #5      _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:394:13)
    #6      _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:404:15)
    #7      _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
    #8      _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)
    #9      _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)
    #10     respDecoder.<anonymous closure> (package:redis_dart/src/utils/resp_utils.dart:11:30)
    #11     _HandlerEventSink.close (dart:async/stream_transformers.dart:236:17)
    #12     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)
    #13     _RootZone.runGuarded (dart:async/zone.dart:1534:10)
    #14     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:394:13)
    #15     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:404:15)
    #16     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
    #17     _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:741:19)
    #18     _StreamController._closeUnchecked (dart:async/stream_controller.dart:596:7)
    #19     _StreamController.close (dart:async/stream_controller.dart:589:5)
    #20     _Socket._onData (dart:io-patch/socket_patch.dart:2167:21)
    #21     _RootZone.runUnaryGuarded (dart:async/zone.dart:1546:10)
    #22     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
    #23     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
    #24     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
    #25     _StreamController._add (dart:async/stream_controller.dart:607:7)
    #26     _StreamController.add (dart:async/stream_controller.dart:554:5)
    #27     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1703:35)
    #28     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1201:18)
    #29     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
    #30     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
    #31     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:120:13)
    #32     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)
    
    opened by benzsuankularb 0
Owner
Gabriel Pacheco
Computer Engineer
Gabriel Pacheco
Feature-rich and easy-to-use Minecraft Fallout server bot.

更好的 Minecraft 廢土伺服器機器人 ?? 介紹 這是個具有許多功能的廢土機器人,且完全免費與開源 另一大特色就是具有容易操作的界面,而不是傳統的小黑窗,讓任何人都能夠輕鬆使用~ 詳細功能請看 這裡 祝您使用愉快! 立即下載 ?? 下載 本軟體支援 Windows、Linux、macOS 作

菘菘 9 Dec 23, 2022
Easy to use open source Hub 🕸️ to control your smart devices from one app.

CyBear Jinni Hub Welcome! This repository is in charge of controlling smart devices and is part of the CyBear Jinni Smart Home system. The software is

CyBear Jinni 26 Nov 23, 2022
Easy to use open source Hub 🕸️ to control your smart devices from one app.

CyBear Jinni Hub Welcome! This repository is in charge of controlling smart devices and is part of the CyBear Jinni Smart Home system. The software is

CyBear Jinni 13 Jul 22, 2021
Super easy mood tracking app to demonstrate use of the Firebase Local Emulator Suite

Mood Tracker Example App in Flutter This is a simple example app showing how to use Cloud Functions and the Firebase Local Emulator inside a Flutter a

Andrea Bizzotto 8 Oct 14, 2022
A declarative library with an easy-to-use interface for building Flutter applications on AWS.

Amplify Flutter AWS Amplify provides a declarative and easy-to-use interface across different categories of cloud operations. Our default implementati

AWS Amplify 1.1k Jan 5, 2023
Dart/Flutter package for using Elastic App Search through a simple API returning easy to handle objects

Dart/Flutter package for using Elastic App Search through a simple API returning easy to handle objects This package is a ready-to-use API for Elastic

Julien Le Bren 5 Nov 16, 2022
Provide easy and flexible way to show SnackBar. Simple text, undo, and error style are supported.

snack_bar_presenter Provide easy and flexible way to show SnackBar. Simple text, undo, and error style are supported. . . . Usage import 'package:exam

Masayuki Ono (mono) 8 Nov 30, 2020
A simple, modern AppImageHub Client, powered by flutter.

AppImagePool Simple AppImageHub Client Main Features FLOSS and non profit app Simple categories Download from github directly, no extra-server involve

Prateek SU 490 Jan 1, 2023
ThingsBoard PE API client library for Dart developers.

ThingsBoard PE API client library for Dart developers. It's compatible with TB PE 3.3.0. Usage A simple usage example: import 'package:thingsboard_pe_

ThingsBoard - Open-source IoT Platform 45 Sep 28, 2022
Wallet Connect client in Dart.

Wallet Connect Wallet Connect client in dart highly inspired from wallet-connect-kotlin by Trust Wallet. Usage import 'package:wallet_connect/wall

null 101 Dec 29, 2022