Skip to main content

AgenticCache

This is a Cache file escpecially for Agentic approaches .

agent_core

A Python package for advanced memory management and task queuing, designed for agentic systems, AI development, and high-concurrency applications. It includes hierarchical memory, caching mechanisms, and a priority-based task queue to handle complex, stateful workflows efficiently.

Features

  • Hierarchical Memory: Multi-level storage (short-term, working, long-term, context) with prefetching, indexing, and automatic consolidation.
  • Caching Systems: LRU cache, FIFO buffers, and TTL-based result caching with background expiration.
  • Task Queuing: Priority queue for async coroutines with stats tracking and thread safety.
  • Thread-Safe: All operations use reentrant locks for concurrent access.
  • Configurable: Extensive config options for capacities, TTLs, thresholds, and more.
  • Extensible: Easy to integrate into agent-based systems for memory persistence and event handling.

Installation

Install via pip:

 pip install agentic_cache

or from source:

git clone https://github.com/Abinayasankar-co/AgenticCache.git
cd agentic_cache
python setup.py install

Quick Start

import logging
from agent_core import HierarchicalMemory, TaskQueue

# Setup logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

# Configure and initialize memory
config = {
    "short_term_capacity": 200,
    "history_size": 500,
    "result_cache_ttl": 7200,
    "prefetch_enabled": True,
    "prefetch_patterns": {"user_data": ["profile", "history"]}
}
memory = HierarchicalMemory(config)

# Store and retrieve data
memory.put("user_id", 12345, namespace="working", persistent=True)
value = memory.get("user_id")  # Returns 12345

# Record an event
memory.record_event({"type": "login", "timestamp": time.time()})

# Initialize task queue
queue = TaskQueue(num_workers=3)
queue.start()

# Submit an async task (example coroutine)
async def example_coro(x):
    await asyncio.sleep(1)
    return x * 2

result = await queue.submit(example_coro, 10)  # Returns 20

# Stop queue when done
queue.stop()

Documentation

See USAGE.md for detailed usage and API reference.

Contributing

Pull requests welcome! Please follow standard Python conventions.

License

Apache License

AgenticCache — Usage

This document explains how to install and use the AgenticCache package. It includes instructions for the CLI entry point and programmatic usage.

Install (editable/development)

From the project root (where setup.py lives), install in editable mode:

python -m pip install -e .

To build a wheel and sdist:

python -m pip install build; python -m build

CLI

A console script agentic-cache is provided. After installing the package, run:

agentic-cache --help

Examples:

  • Put a key into memory:
agentic-cache memory --put name Alice --namespace working
  • Get a key from memory:
agentic-cache memory --get name --namespace working
  • Submit a simple numeric task to the queue:
agentic-cache queue --submit 5 --priority 2

Notes: the CLI uses the main() function in AgenticCache/cli.py which instantiates HierarchicalMemory and TaskQueue using default parameters.

Programmatic usage

Import and use the classes directly:

from AgenticCache.memory import HierarchicalMemory
from AgenticCache.task_queue import TaskQueue

# create memory and queue
memory = HierarchicalMemory({
    "short_term_capacity": 100,
    "history_size": 500,
    "result_cache_ttl": 3600,
    "prefetch_enabled": True,
    "prefetch_patterns": {"user_id": ["profile"]}
})
queue = TaskQueue(num_workers=3)

# store and retrieve
memory.put("key", "value", namespace="working")
print(memory.get("key", namespace="working"))

# submit a coroutine task
async def my_task(x):
    await asyncio.sleep(1)
    return x * 2

import asyncio
result = asyncio.run(queue.submit(my_task, 7))
print(result)

Notes and caveats

  • The package requires Python 3.8+. Ensure your environment meets that requirement.
  • If you installed editable (-e), changes in the source are available immediately.
  • The CLI and examples assume default constructors from the package files; tune parameters to your needs.

If you need a pyproject.toml or specific dependency pins, add them to the repo or ask me to create them for you.

Release files for agentic-cache 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentic-cache 0.1.0
File Size Uploaded
agentic_cache-0.1.0.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentic-cache 0.1.0
File Interpreter ABI Platform
agentic_cache-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.0 kB

Release files / agentic_cache-0.1.0.tar.gz

Download URL agentic_cache-0.1.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0991fda5dfd964b03c8478f48281fab65837f7c65628120dc6fb459eb039b7f2
BLAKE2b-256 checksum
How to use checksums
eb39701ce74b783416adca3a3719c9b550470627c214e8f094f2a76492cc1597
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / agentic_cache-0.1.0-py3-none-any.whl

Download URL agentic_cache-0.1.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6925f08738d6f435ba3821cf19c6d5894e870b5b13c266f4f922ae475b7708f
BLAKE2b-256 checksum
How to use checksums
b270d324d933f0ff05998f16bf3969d820f95cc037ef09c6430468f276916544
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page