_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN
Let's talk

Redis — fast cache and session management

10. 07. 2014 1 min read CORE SYSTEMSdevelopment
Redis — fast cache and session management

Our Java application had a performance problem. Every request hit the database, even for data that changed once an hour. Redis as a cache layer reduced response time from 200 ms to 2 ms and offloaded 95% of queries from the database.

Why Redis, not Memcached

Redis does more than key-value — hashes, lists, sets, sorted sets. It also offers persistence (RDB, AOF), replication, and Sentinel for HA. More than a cache — a legitimate database for specific use cases.

Cache for the REST API

public List<Product> getProducts() {
    String cached = jedis.get("products:all");
    if (cached != null) {
        return objectMapper.readValue(cached, productListType);
    }
    List<Product> products = productRepository.findAll();
    jedis.setex("products:all", 3600, objectMapper.writeValueAsString(products));
    return products;
}

Session store and rate limiting

With Spring Session, Redis as a session store is trivial — one annotation. Sessions survive a restart and are shared across instances. Redis INCR+EXPIRE for rate limiting: key = IP + minute, limit 100 req/min.

Operational tips

  • Set maxmemory with the allkeys-lru eviction policy
  • Do not use KEYS * in production — use SCAN
  • Set TTL on cache keys
  • Monitor the memory fragmentation ratio

Redis belongs in every stack

Simple to operate, fast, versatile. As a cache, session store, or message broker — Redis has a place in every application that needs speed.

rediscacheperformancejava
Share:

CORE SYSTEMS

Stavíme core systémy a AI agenty, které drží provoz. 15 let zkušeností s enterprise IT.

Need help with implementation?

Our experts can help with design, implementation, and operations. From architecture to production.

Contact us