From 387cef83e38e1376c1b21832621392e410a37eeb Mon Sep 17 00:00:00 2001 From: ITPEY <52120725+itpey@users.noreply.github.com> Date: Thu, 2 May 2024 16:57:58 +0330 Subject: [PATCH] Update README.md --- README.md | 71 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 2fe215c..dddf0d4 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,30 @@ -# Remo +[//]: # "Attendees: itpey" +[//]: # "Tags: #itpey #go #remo #golang #go-lang #n-memory #key-value #storage" -[![Go Reference](https://pkg.go.dev/badge/github.com/itpey/remo.svg)](https://pkg.go.dev/github.com/itpey/remo) -[![license](https://img.shields.io/github/license/itpey/remo)](https://github.com/itpey/remo/blob/main/LICENSE) +
+Remo is a Go package that provides in-memory key-value storage with expiration capabilities. It is designed to be a simple and efficient way to manage data with an optional time-to-live (TTL) duration for keys. +
-## Features +# Features - In-memory key-value storage with optional TTL (time-to-live). - Thread-safe operations with efficient read and write locking. - Automatic cleanup of expired keys. - Simple and straightforward API. -## Installation +# Installation You can install Remo using the Go module system: @@ -34,9 +32,9 @@ You can install Remo using the Go module system: go get github.com/itpey/remo ``` -## Usage +# Usage -### Creating a Storage Instance +## Creating a Storage Instance To get started, create a new instance of the Storage struct: @@ -44,11 +42,11 @@ To get started, create a new instance of the Storage struct: store := remo.New() ``` -### Setting and Retrieving Values +## Setting and Retrieving Values You can use the `Set` and `Get` methods to store and retrieve key-value pairs, with the option to set a time-to-live (TTL) duration for keys. -#### Setting a Key with No Expiration +### Setting a Key with No Expiration To set a key with no expiration, simply pass a TTL of 0: @@ -57,7 +55,7 @@ To set a key with no expiration, simply pass a TTL of 0: store.Set("myKey", "myValue", 0) ``` -#### Setting a Key with a Specific TTL +### Setting a Key with a Specific TTL You can also set a key with a specific TTL duration, which represents the time the key will be retained in the storage. For example, to set a key that expires in 30 minutes: @@ -66,7 +64,7 @@ You can also set a key with a specific TTL duration, which represents the time t store.Set("myKey", "myValue", 30 * time.Minute) ``` -#### Retrieving a Value +### Retrieving a Value To retrieve a value by key, use the `Get` method. It returns the value associated with the key and an error if the key does not exist or has expired: @@ -79,14 +77,15 @@ if err != nil { } ``` -### Deleting Keys +## Deleting Keys You can delete keys using the `Delete` method: + ```go store.Delete("myKey") ``` -### Automatic Cleanup +## Automatic Cleanup Remo includes an automatic cleanup feature that removes expired keys at a specified interval. You can start and stop this feature using the following methods: @@ -98,7 +97,7 @@ store.StartCleanup(10 * time.Minute) store.StopCleanup() ``` -### Resetting the Storage +## Resetting the Storage Remo provides a convenient `Reset` method that allows you to clear all keys from the storage. This is useful when you need to start with an empty key-value store. Here's how to use the `Reset` method: @@ -106,7 +105,7 @@ Remo provides a convenient `Reset` method that allows you to clear all keys from store.Reset() ``` -## Running Tests +# Running Tests To run tests for Remo, use the following command: @@ -114,7 +113,7 @@ To run tests for Remo, use the following command: go test github.com/itpey/remo ``` -## Running Benchmarks +# Running Benchmarks To run benchmarks for Remo, use the following command: @@ -122,6 +121,16 @@ To run benchmarks for Remo, use the following command: go test -bench=. github.com/itpey/remo ``` -## License +# Feedback and Contributions + +If you encounter any issues or have suggestions for improvement, please [open an issue](https://github.com/itpey/remo/issues) on GitHub. + +We welcome contributions! Fork the repository, make your changes, and submit a pull request. + +# License + +Remo is open-source software released under the Apache License, Version 2.0. You can find a copy of the license in the [LICENSE](https://github.com/itpey/remo/blob/main/LICENSE) file. + +# Author -This package is distributed under the Apache License, Version 2.0. See the [LICENSE](https://github.com/itpey/remo/blob/main/LICENSE) file for more details. +Chunker was created by [itpey](https://github.com/itpey)