Metastatic.Semantic.Domains.Cache (Metastatic v0.10.4)

View Source

Cache operation patterns for semantic enrichment.

This module defines patterns for detecting cache operations across multiple languages and caching libraries. Patterns are registered with the Metastatic.Semantic.Patterns registry at module load time.

Supported Libraries

Elixir

  • Cachex - In-memory cache with TTL support
  • ConCache - ETS-based caching
  • Nebulex - Distributed caching
  • ETS - Erlang Term Storage

Python

  • redis-py - Redis client
  • python-memcached - Memcached client
  • Flask-Caching - Flask caching extension
  • django-cache - Django caching framework

Ruby

  • Rails.cache - Rails caching API
  • Dalli - Memcached client
  • redis-rb - Redis client

JavaScript

  • node-cache - In-memory caching
  • redis/ioredis - Redis clients
  • memcached - Memcached client

Cache Operations

OperationDescription
:getRetrieve value from cache
:setStore value in cache
:deleteRemove value from cache
:clearClear all cache entries
:invalidateInvalidate cache entries
:expireSet/update TTL
:existsCheck if key exists
:incrementIncrement numeric value
:decrementDecrement numeric value
:ttlGet time-to-live
:fetchGet or compute value

Pattern Structure

Each pattern is a tuple of {pattern, spec} where:

  • pattern - String or Regex to match function names
  • spec - Map with operation details:
    • :operation - The cache operation type
    • :framework - The caching library identifier
    • :extract_target - Strategy for extracting cache key

Summary

Functions

Registers all cache patterns for all languages.

Functions

register_all()

@spec register_all() :: :ok

Registers all cache patterns for all languages.

Called automatically when the module is loaded. Can also be called manually to re-register patterns (e.g., after clearing).