redis

Generated by tinox doc

RESP2 client for Redis/Valkey (single-node, request/response commands: GET, SET, SETEX, DEL, EXPIRE, INCR). Use it for a cache or session store shared across multiple server processes — tinox.core.cache is in-process only and can't do that.

ModuleVersionGroup
socket1.0.0tinox.core

Session cache

import tinox.core.redis;

class Main
{
    fnc main() -> Int32
    {
        let client: RedisClient = RedisClient::connect("localhost", 6379);
        if client.conn <= 0
        {
            println("connect failed: " + client.errorMessage);
            return 1;
        }

        client.setEx("session:abc", "user-42", 3600);

        let value: String = client.get("session:abc");
        if client.lastGetFound()
        {
            println("session:abc = " + value);
        }
        else
        {
            println("cache miss");
        }

        client.incr("visits:abc");
        client.close();
        return 0;
    }
}

fn httpConnReadLine(conn: Int64) → String

fn tinoxBytesToString(bytes: List<Int64>) → String

class RedisClient

Fields

connInt64
errorMessageString
getFoundBool
incrOkBool

Methods

fn connect(host: String, port: Int64) → RedisClient
fn ping() → Bool
fn get(key: String) → String
fn lastGetFound() → Bool
fn set(key: String, value: String) → Bool
fn setEx(key: String, value: String, ttlSeconds: Int64) → Bool
fn del(key: String) → Bool
fn expire(key: String, ttlSeconds: Int64) → Bool
fn incr(key: String) → Int64
fn lastIncrOk() → Bool
fn close() → Nothing
fn sendCommand(args: List<String>) → Nothing