-- v1.9_redis_cache.sql
-- Mejora #9: Caché de Stock con Redis
--
-- Adds Redis-backed stock caching for sub-millisecond lookups.
-- No database schema changes required — caching is handled entirely
-- in the application layer (pos/services/redis_stock_cache.py).
--
-- Invalidation strategy:
--   - Every stock mutation (SALE, PURCHASE, RETURN, ADJUST, TRANSFER, INITIAL)
--     invalidates the affected Redis keys immediately in Python code.
--   - Cache TTL is 5 minutes (configurable via REDIS_STOCK_TTL env var).
--   - On Redis miss, stock is computed from PostgreSQL SUM query and cached.
--
-- Prerequisites:
--   - Redis server installed and running (default: localhost:6379)
--   - redis-py library installed
--
SELECT 'v1.9 redis cache migration applied' as status;
