Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter & Redis client

Tags:

php

redis

flutter

I have (Chat) Flutter mobile app which uses Lumen as backend. However, I want to cache some things and would like to use Redis for this purpose. Is there a way how Flutter app can speak with Redis? Should I install some package for this or make HTTP request for every caching?

My goal is to store last conversation message.

On backend side I can do something like this:

Redis::hSet('chat1', 'message', 'hello');

But I am not sure how this is going to affect performance... Therefore it would be better to have Redis client on Frontend side (Flutter).

like image 572
harunB10 Avatar asked Nov 22 '25 20:11

harunB10


1 Answers

You can use package https://pub.dev/packages/redis
This package is Redis client for Dart

code snippet

import 'package:redis/redis.dart';
...
RedisConnection conn = new RedisConnection();
conn.connect('localhost',6379).then((Command command){
    command.send_object(["SET","key","0"]).then((var response)
        print(response);
    )
}
like image 51
chunhunghan Avatar answered Nov 24 '25 08:11

chunhunghan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!