Giter Site home page Giter Site logo

deputy_redis's Introduction

ioredis v5 minimal bindings for Haxe (current target: node) with tink_core promises

a totally minimal version with partial support

See API, in case you need to bind more functions, at https://luin.github.io/ioredis/classes/Redis.html

Prerequisite

To install you should use lix. Then:

lix install github:grepsuzette/deputy_redis
npm install ioredis

Example

This kind of stupid example doesn't give justice to tink. It can help you out though. Also see the unit tests.

import deputy.redis.Redis;
import deputy.redis.RedisClient;
import js.Browser.alert;
using tink.CoreApis;

Redis.usable()                              // connects. 
     .handle( run );     

function run(out:Outcome<RedisClient, Error>) {
    switch out {
        case Failure(err): 
            alert(err.toString());
        case Success(client): 
            client.set("hello", "world");   // return a tink.Promise, which we don't handle

            client.mset([ 
                new Pair("current_city", "NY"), 
                new Pair("current_month", "April") 
            ]).handle(_ -> console.log("done"));

            client.mget(["cats", "dogs"])
                  .handle(out -> switch out {
                        case Success(pairs):
                            for (pair in pairs) {
                                console.log('There are ${pair.b} ${pair.a}');
                            }
                        case Failure(e):
                            console.error(e.toString());
                  });
    }
}

deputy_redis's People

Contributors

grepsuzette avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.