tritium

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Example
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/we-be/tritium/pkg/tritium"
)

func main() {
	// Create a new client
	client, err := tritium.NewClient(&tritium.ClientOptions{
		Address: "localhost:40585",
		Timeout: 5 * time.Second,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer client.Close()

	// Set a value
	err = client.Set("hello", []byte("world"), nil)
	if err != nil {
		log.Fatal(err)
	}

	// Get the value back
	value, err := client.Get("hello")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Value: %s\n", string(value))
}
Output:

Value: world

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a Tritium RPC client

func NewClient

func NewClient(opts *ClientOptions) (*Client, error)

NewClient creates a new Tritium client

func (*Client) Close

func (c *Client) Close() error

Close closes the client connection

func (*Client) Get

func (c *Client) Get(key string) ([]byte, error)

Get retrieves a value

func (*Client) Set

func (c *Client) Set(key string, value []byte, ttl *int) error

Set stores a value with an optional TTL

type ClientOptions

type ClientOptions struct {
	Address string
	Timeout time.Duration
}

ClientOptions contains options for creating a new client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL