Skip to content

Latest commit

 

History

History
148 lines (102 loc) · 2.17 KB

File metadata and controls

148 lines (102 loc) · 2.17 KB

rcache

Fast and simple in-memory cache tool

Overview

rcache is a command-line based key-value cache tool with TTL (Time To Live) support. Implemented in Go, it provides fast and concurrency-safe operations.

Features

  • 🚀 Fast in-memory cache
  • ⏱️ TTL (Time To Live) support
  • 🔒 Concurrency-safe operations
  • 📝 Simple CLI interface
  • 🧪 Comprehensive test coverage

Installation

Build from source

git clone https://github.com/rRateLimit/rcache.git
cd rcache
make build

Install using Go

go install github.com/rRateLimit/rcache/cmd/rcache@latest

Usage

Basic Commands

Set a key-value pair

# Basic set
rcache set mykey "Hello, World!"

# Set with TTL (expires after 10 seconds)
rcache set mykey "Hello, World!" --ttl 10s

# TTL can be specified in seconds (s), minutes (m), or hours (h)
rcache set mykey "Hello, World!" --ttl 5m
rcache set mykey "Hello, World!" --ttl 1h

Get a value

rcache get mykey
# Output: Hello, World!

Delete a key

rcache delete mykey
# Output: Deleted: mykey

List all keys

rcache list

# Output as JSON
rcache list --json

Check cache size

rcache size
# Output: Cache size: 3

Clear cache

rcache clear
# Output: Cache cleared

Development

Requirements

  • Go 1.21 or higher

Build

make build

Run tests

make test

Format code

make fmt

Run all tasks

make all

Project Structure

rcache/
├── cmd/
│   └── rcache/
│       └── main.go          # Main entry point
├── internal/
│   ├── cache/
│   │   ├── cache.go         # Cache core implementation
│   │   └── cache_test.go    # Cache tests
│   └── cli/
│       ├── commands.go      # CLI command implementation
│       └── commands_test.go # CLI tests
├── go.mod
├── go.sum
├── Makefile
└── README.md

License

MIT License

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Author

rRateLimit