introspect

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2025 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package introspect provides utilities for runtime inspection and type checking of cache backends. It includes helpers to determine the specific implementation type of cache backends at runtime, enabling conditional logic based on the underlying storage mechanism.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheBackendChecker

type CacheBackendChecker[T backend.IBackendConstrain] struct {
	Backend     backend.IBackend[T]
	BackendType string
}

CacheBackendChecker is a generic helper struct that provides runtime type checking capabilities for cache backends. It allows inspection of the underlying backend implementation to determine its specific type (e.g., InMemory, Redis) without requiring direct type assertions in client code.

The generic type parameter T must satisfy the backend.IBackendConstrain interface, ensuring type safety across different backend implementations.

Example usage:

checker := &CacheBackendChecker[string]{
    Backend:     myBackend,
    BackendType: "redis",
}
if checker.IsRedis() {
    // Handle Redis-specific logic
}

func (*CacheBackendChecker[T]) GetRegisteredType

func (c *CacheBackendChecker[T]) GetRegisteredType() string

GetRegisteredType returns the backend type as a string.

func (*CacheBackendChecker[T]) IsInMemory

func (c *CacheBackendChecker[T]) IsInMemory() bool

IsInMemory returns true if the backend is an InMemory.

func (*CacheBackendChecker[T]) IsRedis

func (c *CacheBackendChecker[T]) IsRedis() bool

IsRedis returns true if the backend is a Redis.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL