Golang Cache component - Multiple drivers

Cachego

Build Status Codecov branch GoDoc Go Report Card License

Simple interface for caching

Installation

Cachego requires Go 1.13 or later.

go get github.com/faabiosr/cachego

Usage

package main

import (
	"log"
	"time"

	"github.com/faabiosr/cachego/sync"
)

func main() {
	cache := sync.New()

	if err := cache.Save("user_id", "1", 10*time.Second); err != nil {
		log.Fatal(err)
	}

	id, err := cache.Fetch("user_id")
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("user id: %s \n", id)

	keys := cache.FetchMulti([]string{"user_id", "user_name"})

	for k, v := range keys {
		log.Printf("%s: %s\n", k, v)
	}

	if cache.Contains("user_name") {
		cache.Delete("user_name")
	}

	if _, err := cache.Fetch("user_name"); err != nil {
		log.Printf("%v\n", err)
	}

	if err := cache.Flush(); err != nil {
		log.Fatal(err)
	}
}

Supported drivers

Documentation

Read the full documentation at https://pkg.go.dev/github.com/faabiosr/cachego.

Development

Requirements

Makefile

// Clean up
$ make clean

//Run tests and generates html coverage file
$ make cover

// Up the docker containers for testing
$ make docker

// Format all go files
$ make fmt

//Run linters
$ make lint

// Run tests
$ make test

License

This project is released under the MIT licence. See LICENSE for more details.

Owner
Fabio Ribeiro
Software Engineer
Fabio Ribeiro
Similar Resources

💲 Golang, Go Fiber, RabbitMQ, MongoDB, Docker, Kubernetes, GitHub Actions

💲 Golang, Go Fiber, RabbitMQ, MongoDB, Docker, Kubernetes, GitHub Actions

Bank Projeto para simular empréstimos financeiros em um banco para clientes Tecnologias Utilizadas Golang MongoDB RabbitMQ Github Actions Docker Hub D

Dec 9, 2022

HDFS for Go - This is a native golang client for hdfs.

HDFS for Go This is a native golang client for hdfs. It connects directly to the namenode using the protocol buffers API. It tries to be idiomatic by

Dec 24, 2022

A Golang implemented Redis Server and Cluster.

A Golang implemented Redis Server and Cluster.

Godis is a golang implementation of Redis Server, which intents to provide an example of writing a high concurrent middleware using golang.

Dec 28, 2022

Go-odm, a Golang Object Document Mapping for MongoDB.

Go-odm, a Golang Object Document Mapping for MongoDB.

A project of SENROK Open Source Go ODM Go-odm, a Golang Object Document Mapping for MongoDB. Table of contents Features Installation Get started Docum

Nov 4, 2022

golang connection pool

Connection pool for golang

Dec 13, 2021

Implemented Cassandra DB to GoLang API

Implemented Cassandra DB to GoLang API

Implemented Cassandra DB to GoLang API

Jun 7, 2022

A CouchDB client in Go(Golang)

pillow pillow is a CouchDB client in Go(Golang). Resources Installation Usage Example Installation Install pillow as you normally would for any Go pac

Nov 9, 2022

Redis client for Golang

Redis client for Golang

Redis client for Golang To ask questions, join Discord or use Discussions. Newsl

Dec 23, 2021

Redis client for Golang

Redis client for Golang

Redis client for Golang Discussions. Newsletter to get latest updates. Documentation Reference Examples RealWorld example app Other projects you may l

Dec 30, 2021
Comments
  • Solving implicit assignment of unexported field issue in cachego.Mongo

    Solving implicit assignment of unexported field issue in cachego.Mongo

    I was receiving the following error when trying to use the Mongo cache (as documented):

    implicit assignment of unexported field 'collection' in cachego.Mongo literal

    For me, exporting Mongo.Collection fixed this issue.

    Please note, this issue may affect other cache drivers as well, but I did not test those.

  • Add support for official mongodb driver

    Add support for official mongodb driver

    Closes #10

    Changes

    • added a new package mongoo : Mongo Official as the cachego already has mongo package.
    • added test for mongoo_test

    Tests

    • tested make test
  • Support files

    Support files

    • Add golang dep for downloading test dependencies
    • Create a makefile for supporting test and test-coverage
    • Update documentation with new development features
    • Update travis file to download and install golang dep
    • Drop support for GO 1.5 to 1.7
Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package

Go-MySQL-Driver A MySQL-Driver for Go's database/sql package Features Requirements Installation Usage DSN (Data Source Name) Password Protocol Address

Jan 4, 2023
Lightweight Golang driver for ArangoDB

Arangolite Arangolite is a lightweight ArangoDB driver for Go. It focuses on pure AQL querying. See AranGO for a more ORM-like experience. IMPORTANT:

Sep 26, 2022
Golang client for redislabs' ReJSON module with support for multilple redis clients (redigo, go-redis)

Go-ReJSON - a golang client for ReJSON (a JSON data type for Redis) Go-ReJSON is a Go client for ReJSON Redis Module. ReJSON is a Redis module that im

Dec 25, 2022
redis client implement by golang, inspired by jedis.

godis redis client implement by golang, refers to jedis. this library implements most of redis command, include normal redis command, cluster command,

Dec 6, 2022
Go Memcached client library #golang

About This is a memcache client library for the Go programming language (http://golang.org/). Installing Using go get $ go get github.com/bradfitz/gom

Jan 8, 2023
Neo4j REST Client in golang

DEPRECATED! Consider these instead: https://github.com/johnnadratowski/golang-neo4j-bolt-driver https://github.com/go-cq/cq Install: If you don't ha

Nov 9, 2022
Neo4j client for Golang

neoism - Neo4j client for Go Package neoism is a Go client library providing access to the Neo4j graph database via its REST API. Status System Status

Dec 30, 2022
Type-safe Redis client for Golang

Redis client for Golang ❤️ Uptrace.dev - distributed traces, logs, and errors in one place Join Discord to ask questions. Documentation Reference Exam

Jan 1, 2023
Type-safe Redis client for Golang

Redis client for Golang ❤️ Uptrace.dev - distributed traces, logs, and errors in one place Join Discord to ask questions. Documentation Reference Exam

Jan 4, 2023
Golang driver for ClickHouse

ClickHouse Golang SQL database driver for Yandex ClickHouse Key features Uses native ClickHouse tcp client-server protocol Compatibility with database

Jan 8, 2023