If you’re running IBM i, you’re sitting on a powerhouse for business workloads, trusted by industries like finance, retail, and manufacturing for its rock-solid reliability and integrated Db2 for i database. But in an era of real-time applications—think e-commerce, IoT, or live analytics—speed is everything. What if you could supercharge IBM i with Redis, the world’s fastest in-memory data store? That’s where Redis400 comes in: my custom-built integration that brings Redis’s lightning-fast capabilities to IBM i, tailored for flexibility, performance, and native compatibility. Whether you’re caching API responses, managing web sessions, or streaming live data, Redis400 makes your IBM i applications soar while staying true to the platform’s legacy roots.

As I prepare er400.io for its 2025 launch—a hub for IBM i modernization tools and tutorials—Redis400 is a flagship project showcasing my knack for system-level solutions. It’s open-source, available at https://github.com/krakadin/redis400, and built to empower developers to make IBM i systems talk smarter. Let’s dive into what Redis400 is, how it works, and why it’s a game-changer for IBM i.

What is Redis400?

Redis400 is a set of SQL User-Defined Functions (UDFs) written in ILE C, designed to integrate Redis with IBM i’s Db2 for i. These functions let you interact with a Redis server directly from SQL queries, RPG, COBOL, or any ILE language, enabling high-performance data operations without leaving the IBM i ecosystem. The core functions include:

  • REDIS_SET: Stores a key-value pair in Redis (e.g., cache a customer record).
  • REDIS_GET: Retrieves a value by key, with sub-millisecond latency.
  • REDIS_INCR: Increments an integer counter (e.g., for order numbers or analytics).
  • REDIS_DEL: Deletes a key, freeing memory.
  • REDIS_EXPIRE (added March 12, 2025): Sets a time-to-live (TTL) for a key, ideal for temporary data like sessions.
  • REDIS_TTL (added March 12, 2025): Checks a key’s remaining TTL, useful for managing expirations.
  • REDIS_PING (added March 30, 2025): Tests Redis server connectivity, returning “PONG” if successful.

Each function is compiled into a standalone ILE module, which you can link individually into your ILE programs (RPG, COBOL) for lightweight integration. Alternatively, they’re bundled into a service program (redisile.srvpgm), exposing UDFs for SQL access, so you can call Redis operations like SELECT REDIS_GET(‘key’) from Db2. This dual approach—ILE modules for programmatic control and SQL UDFs for database-driven apps—gives you unmatched flexibility to modernize IBM i applications.

Redis400 is IBM i-native, built around socket programming to communicate with Redis over TCP/IP. It handles EBCDIC-to-ASCII conversions transparently, ensuring compatibility with IBM i’s unique encoding while leveraging Redis’s ASCII-based protocol. The result? You can automate tasks like setting session data from a CL script, fetch cached reports from an RPG app without Db2 queries, or stream real-time events from a PHP web app—all with Redis’s blazing speed.

Why Redis400 for IBM i?

With over 100,000 IBM i installations worldwide, the platform is a cornerstone for enterprises, offering unmatched stability and a tightly integrated stack (Db2, RPG, CL). But its strength—optimized for transactional workloads—can be a bottleneck for real-time demands, where frequent Db2 queries or complex joins slow things down. Redis, a NoSQL in-memory database, excels at low-latency tasks like caching, session management, and event streaming, complementing Db2’s relational power. Redis400 bridges these worlds, letting you:

  • Cache Data: Store hot Db2 records (e.g., product catalogs) in Redis, cutting query times from milliseconds to microseconds.
  • Manage Sessions: Handle web app sessions with REDIS_EXPIRE, perfect for PHP or Node.js frontends on IBM i.
  • Track Analytics: Use REDIS_INCR for real-time counters, like page views or order numbers.
  • Process Events: Leverage Redis streams (via future UDFs) for logging user actions or IoT data.
  • Rate Limit APIs: Implement counters to secure web services, enhancing IBM i’s HTTP server capabilities.

Unlike generic Redis clients (e.g., ioredis for Node.js or redis-py for Python), Redis400 is tailored for IBM i’s PASE (Portable Application Solutions Environment) and ILE (Integrated Language Environment). It eliminates middleware complexity, making Redis accessible to traditional IBM i developers (RPG, COBOL) and modern ones (PHP, SQL) alike.

How It Works: Technical Deep Dive

Redis400’s architecture is a masterclass in IBM i engineering, blending legacy compatibility with modern performance:

  • ILE C Functions: Each UDF (e.g., REDIS_SET, REDIS_GET) is written in ILE C, compiled into modules (REDISGET, REDISSET, etc.) using IBM i’s CRTCMOD. These modules are bound into a service program (redisile.srvpgm) for SQL access or linked directly into ILE programs.
  • Socket Programming: Redis400 uses TCP/IP sockets to connect to a Redis server (local via PASE or remote). It sends Redis commands in RESP (REdis Serialization Protocol) format, ensuring
  • EBCDIC-ASCII Conversion: IBM i uses EBCDIC encoding, while Redis expects ASCII. Redis400 handles conversions natively, so your RPG or SQL code doesn’t need to manage encoding.
  • SQL UDFs: Registered in Db2, UDFs like REDIS_GET or REDIS_EXPIRE are callable from SQL queries, CL scripts, or embedded in RPG/COBOL via SQL, making integration seamless.
  • Makefile Automation: A Makefile streamlines compilation, binding, and deployment, creating the REDIS400 library, modules, service program, and UDFs with a single gmake command.

Getting Started with Redis400

Ready to unleash Redis400? Here’s how to set it up:

  1. Prerequisites:
    • IBM i Access: An IBM i system (V7.3+) with ILE C compiler (5770WDS 51 2911) and SQL.
    • Redis Server: Running locally via PASE (yum install redis) or remotely (e.g., Redis Cloud). Default: 127.0.0.1:6379.
    • Makefile Support: Install make via yum install make in PASE.
    • Git: For cloning the repo (git clone https://github.com/krakadin/redis400).
  2. Install Redis400:
    • Clone the repo and navigate to the directory: cd redis400.
    • Fix Git settings if needed: git config –global core.autocrlf input.
    • Run gmake to:
      • Create the REDIS400 library.
      • Compile C modules (redisget.c, redisset.c, etc.) into ILE modules.
      • Bind modules into redisile.srvpgm.
      • Register UDFs (REDIS_GET, REDIS_SET, etc.) in Db2.
  3. Verify Installation:
    • Check modules: DSPOBJD OBJ(REDIS400/REDISGET) OBJTYPE(*MODULE).
    • Check service program: DSPOBJD OBJ(REDIS400/REDISILE) OBJTYPE(*SRVPGM).
    • Check UDFs: SELECT * FROM QSYS2.SYSFUNCS WHERE SPECIFIC_NAME = ‘REDIS_GET’.
  4. Configure Redis:
    • Edit /QOpenSys/etc/redis.conf (PASE) to bind to 127.0.0.1:6379.
    • Start Redis: redis-server /QOpenSys/etc/redis.conf –daemonize yes.
    • Test connectivity: redis-cli -h 127.0.0.1 -p 6379 PING (expect “PONG”).
  5. Use Redis400:
    • Run SQL queries: SELECT REDIS_GET(‘key’) FROM SYSIBM.SYSDUMMY1.
    • Embed in RPG: Call REDIS_SET to cache data.
    • Script in CL: Automate tasks like session cleanup.

The GitHub repo (https://github.com/krakadin/redis400) includes source code, a Makefile, and examples, tested on IBM i V7.3 and V7.4.

Expanded Use Cases

Redis400 unlocks a range of applications for IBM i, blending legacy and modern needs:

  • E-Commerce: Cache product details to speed up web storefronts, reducing Db2 load. Example: VALUES REDIS_SET(‘product:123’, ‘Laptop, $999’).
  • Session Management: Store web app sessions with REDIS_EXPIRE for PHP apps on IBM i’s HTTP server. Example: SELECT REDIS_EXPIRE(‘session:abc’, 3600).
  • Real-Time Analytics: Track page views or logins with REDIS_INCR. Example: SET views = REDIS_INCR(‘page:home’).
  • Job Queues: Use Redis lists (via future UDFs) for lightweight batch jobs. Example: REDIS_LIST(‘order_queue’, ‘RPUSH’, ‘order:456’).
  • API Rate Limiting: Limit API calls with REDIS_INCR and REDIS_TTL, enhancing security. Example: SELECT REDIS_INCR(‘api:user123’).
  • Health Checks: Use REDIS_PING to monitor Redis server uptime in production. Example: VALUES REDIS_PING().

These use cases make IBM i a contender in modern app development, from web services to IoT.

Why Open Source?

Redis400 is open-source under the MIT License, reflecting my belief in collaborative innovation. The GitHub repo (https://github.com/krakadin/redis400) is a hub for developers to:

  • Fork and Customize: Adapt Redis400 for your IBM i setup.
  • Contribute: Add UDFs (e.g., HSET, SCAN) or optimize socket performance.
  • Share Ideas: Propose integrations with PHP frameworks or Python, aligning with er400.io’s vision.

The repo includes C source files, a Makefile, and detailed docs, making it accessible to IBM i developers and newcomers. As er400.io gears up for its 2025 launch, Redis400 is a cornerstone, showcasing how open-source tools can modernize legacy systems while fostering community.

Challenges and Future Roadmap

Redis400 is powerful but faces hurdles:

  • Niche Audience: IBM i’s declining developer base (many nearing retirement) limits adoption.
  • PASE Setup: Running Redis locally requires PASE expertise, which can be daunting on older systems.
  • Authentication: Redis400 doesn’t yet support Redis’s AUTH command, requiring unauthenticated servers.
  • Scalability: High-traffic apps may need Redis clusters, demanding network optimization.

Future enhancements include:

  • Support for more Redis commands (APPEND, AUTH, SCAN).
  • A GUI (e.g., like Redis Insight) for managing Redis data on IBM i.

Join the Revolution

Redis400 isn’t just a tool—it’s a movement to keep IBM i thriving in the age of real-time apps. Whether you’re an RPG guru, a PHP developer, or a system admin, Redis400 lets you tap Redis’s speed without leaving IBM i’s ecosystem. Grab it at https://github.com/krakadin/redis400, run the examples, and share your feedback. Got ideas for new UDFs, PHP integrations, or er400.io’s 2025 vision? Hit me up via GitHub or er400.io’s contact form. Let’s build the future of IBM i, one Redis command at a time!

Author: Ernest Rozloznik
Acknowledgments: Thanks to the IBM i and Redis communities for their tools and inspiration.

No Comments Open Source, Redis, SQL

Leave a Reply

Your email address will not be published. Required fields are marked *