Skip to content

v0.1.0

Latest

Choose a tag to compare

@MichaelAJay MichaelAJay released this 26 May 01:53
· 111 commits to main since this release

Go Cache v0.1.0 Release

Go Cache is a flexible and extensible caching library for Go applications that provides a uniform interface for different cache implementations with enterprise-grade features.

πŸš€ Key Features

Core Functionality

  • Unified Cache Interface: Consistent API across all cache providers
  • Multiple Cache Providers: Memory, Redis, Null, and Multi-tier caching support
  • Thread-Safe Operations: Concurrent access with proper synchronization
  • Context-Aware Operations: Full context support for cancellation and timeouts
  • TTL Support: Flexible time-to-live configuration for cache entries

Advanced Capabilities

  • Bulk Operations: Efficient batch get, set, and delete operations
  • Cache Entry Metadata: Detailed tracking of creation time, access patterns, and entry statistics
  • Comprehensive Metrics: Built-in performance monitoring with Prometheus integration
  • Middleware System: Pluggable logging and metrics middleware
  • Serialization Support: Multiple serialization formats including MessagePack via go-serializer

Enterprise Features

  • Cache Manager: Centralized management of multiple cache instances
  • Provider Registration: Dynamic cache provider registration system
  • Configurable Options: Extensive configuration options for different use cases
  • Error Handling: Comprehensive error types for robust error handling

πŸ“¦ Cache Providers

  1. Memory Cache: High-performance in-memory caching for single-instance applications
  2. Redis Cache: Distributed caching with Redis backend for scalable applications
  3. Null Cache: No-op cache for testing and development
  4. Multi Cache: Multi-tier caching strategies

πŸ›  Technical Specifications

  • Go Version: 1.23.3+
  • Dependencies:
    • Redis client (go-redis/redis/v8)
    • Custom logging (go-logger)
    • Metrics collection (go-metrics)
    • Serialization (go-serializer)
    • Prometheus integration
  • Thread Safety: Full concurrent access support
  • Memory Management: Configurable limits and cleanup intervals
  • Serialization: Multiple formats supported via pluggable serializer

πŸ“Š Monitoring & Observability

  • Built-in Metrics: Hit/miss ratios, latency tracking, cache size monitoring
  • Prometheus Integration: Ready-to-use Prometheus metrics exporter
  • Logging Middleware: Comprehensive operation logging with timing information
  • Cache Entry Metadata: Detailed tracking of access patterns and entry lifecycle

πŸ”§ Configuration Options

  • TTL (Time-To-Live) configuration
  • Maximum entries and size limits
  • Cleanup interval settings
  • Redis connection options
  • Custom logger integration
  • Serialization format selection
  • Metrics collection configuration

πŸ“š Examples & Documentation

The release includes comprehensive examples:

  • Basic cache usage patterns
  • Redis integration with various configurations
  • MessagePack serialization examples
  • Prometheus metrics integration
  • Advanced Redis usage patterns

πŸ§ͺ Testing & Quality

  • Comprehensive Test Suite: Extensive unit and integration tests
  • Concurrency Testing: Thread-safety validation
  • Provider Testing: Individual provider validation
  • Edge Case Coverage: Robust error handling and edge case testing
  • Redis Integration Tests: Real Redis instance testing (when available)

🎯 Use Cases

  • Web Applications: Session storage, API response caching
  • Microservices: Distributed caching across service boundaries
  • Data Processing: Intermediate result caching
  • High-Performance Applications: In-memory caching for speed-critical operations
  • Development & Testing: Null cache for testing scenarios

πŸ”„ Best Practices Implemented

  • Interface-Driven Design: Clean separation of concerns
  • Context Propagation: Proper context handling throughout
  • Error Wrapping: Comprehensive error context
  • Resource Management: Proper cleanup and resource disposal
  • Concurrent Safety: Thread-safe operations without performance penalties
  • Extensibility: Plugin architecture for custom providers and middleware

Installation

go get github.com/MichaelAJay/go-cache

Quick Start

package main

import (
    "context"
    "time"

    "github.com/MichaelAJay/go-cache"
    "github.com/MichaelAJay/go-cache/providers/memory"
)

func main() {
    // Create a cache manager
    manager := cache.NewCacheManager()

    // Register the memory cache provider
    manager.RegisterProvider("memory", memory.NewProvider())

    // Create a cache instance
    cache, err := manager.GetCache("memory",
        cache.WithTTL(5*time.Minute),
        cache.WithMaxEntries(1000),
    )
    if err != nil {
        panic(err)
    }

    // Use the cache
    ctx := context.Background()
    cache.Set(ctx, "key", "value", 0)
    value, exists, _ := cache.Get(ctx, "key")
}

This release represents a production-ready caching solution that follows Go best practices and provides the flexibility needed for modern distributed applications.