go-redis-example

command module
v0.0.0-...-a37fdb3 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 3 Imported by: 0

README

Repository Pattern Redis Example

This is a simple example project that demonstrates how to connect to a Redis database using Go and the go-redis library.

Prerequisites

Before running this project, make sure you have the following prerequisites:

Getting Started

Follow the steps below to set up and run the project:

  1. Clone the repository:
$ git clone https://github.com/lucasgrvarela/go-redis-example.git
  1. Change into the project directory:
$ cd go-redis-example
  1. Start a Redis server using Docker:
$ docker run -d -p 6379:6379 --name redis-server redis
  1. Run the Go application:
$ go run *.go
Key set successfully!
Key: 'mykey' retrieved, value: 'myvalue'
  1. Test manually everything worked as expected:
$ docker exec -it redis-server bash
$ redis-cli # run inside the container
127.0.0.1:6379> GET mykey
"myvalue"

Configuration

By default, the Go application connects to Redis running on localhost:6379. If your Redis server is running on a different address or port, you can modify the main.go file and update the Redis server address in the NewRedisClient function.

Contributing

Contributions are welcome! If you find any issues with the project or want to extend it further, feel free to open an issue or submit a pull request.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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