redis

package module
v0.0.0-...-24092c7 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: MIT Imports: 5 Imported by: 0

README

TinyPHP-Redis

package main

import (
	"github.com/go-redis/redis"
	"github.com/kimkit/tinyphp"
	_redis "github.com/kimkit/tinyphp-redis"
	"github.com/kimkit/tinyphp/std"
)

func init() {
	_redis.RegisterRedis()
	_redis.AddRedis("local", redis.NewUniversalClient(&redis.UniversalOptions{
		Addrs: []string{"127.0.0.1:6379"},
	}))
}

func main() {
	src := `
$redis = get_redis("local")->ok();
$redis->call("set", "a", 1);
$a = $redis->call("get", "a")->ok();
var_dump($a);
    `
	stmts, err := tinyphp.ParseSrc(src)
	if err != nil {
		panic(err)
	}
	store := tinyphp.NewStore(std.Funcs, std.Methods)
	if _, err := tinyphp.RunStmts(stmts, store); err != nil {
		panic(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = fmt.Errorf("not found")
)

Functions

func AddRedis

func AddRedis(name string, client redis.UniversalClient)

func GetRedisClient

func GetRedisClient(name string) (redis.UniversalClient, error)

func RegisterRedis

func RegisterRedis()

Types

type Redis

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

func GetRedis

func GetRedis(name string) (*Redis, error)

func (*Redis) GetClient

func (r *Redis) GetClient() redis.UniversalClient

func (*Redis) TypeName

func (r *Redis) TypeName() string

Jump to

Keyboard shortcuts

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