Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
itpey authored Oct 20, 2023
1 parent 239fb27 commit aadf6d3
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Remo

[![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 an in-memory key-value storage with expiration capabilities. It is designed to be a simple and efficient way to manage data with optional time-to-live (TTL) duration for keys.

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.

## Table of Contents

- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
Expand Down Expand Up @@ -36,6 +37,7 @@ go get github.com/itpey/remo
## Usage

### Creating a Storage Instance

To get started, create a new instance of the Storage struct:

```go
Expand All @@ -54,6 +56,7 @@ To set a key with no expiration, simply pass a TTL of 0:
// Set a key with a value and no expiration
store.Set("myKey", "myValue", 0)
```

#### 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:
Expand All @@ -64,7 +67,9 @@ store.Set("myKey", "myValue", 30 * time.Minute)
```

#### 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:

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:

```go
value, err := store.Get("myKey")
if err != nil {
Expand All @@ -75,11 +80,14 @@ if err != nil {
```

### Deleting Keys
You can delete keys using the Delete method:

You can delete keys using the `Delete` method:
```go
store.Delete("myKey")
```

### 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:

```go
Expand All @@ -97,19 +105,23 @@ Remo provides a convenient `Reset` method that allows you to clear all keys from
```go
store.Reset()
```

## Running Tests

To run tests for Remo, use the following command:

```bash
go test github.com/itpey/remo
```

## Running Benchmarks

To run benchmarks for Remo, use the following command:

```bash
go test -bench=. github.com/itpey/remo
```

## License

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.

0 comments on commit aadf6d3

Please sign in to comment.