gowrap icon indicating copy to clipboard operation
gowrap copied to clipboard

Add caching template for gowrap

Open retr0-kernel opened this issue 5 months ago • 1 comments

Add Caching Template for GoWrap

This PR adds a new caching template that automatically instruments Go interfaces with in-memory caching.

Features

  • Smart Caching: Only caches methods with return values
  • Error Handling: Errors are never cached, failed calls always hit the underlying implementation
  • Thread-Safe: Uses sync.RWMutex for concurrent access
  • Configurable: Customizable cache expiration and cleanup intervals
  • Multi-Return Support: Handles both single and multiple return value methods
  • Key Generation: Cache keys based on method name + all parameters

Usage

# Basic usage
gowrap gen -p io -i Reader -t caching -o reader_with_caching.go

# With custom decorator name
gowrap gen -p io -i Writer -t caching -v DecoratorName=CachedWriter -o writer_with_caching.go

retr0-kernel avatar Jul 22 '25 08:07 retr0-kernel

Hey there @hexdigest , Added a caching template that instruments interfaces with in-memory caching using go-cache. Let me know if any changes needed or anything, will do the needful. Thank you.

retr0-kernel avatar Jul 22 '25 09:07 retr0-kernel