NAME

Langertha::Holmgang::Sim::Linux::Redis - Redis on a simulated Linux server — redis-cli, CONFIG GET/SET/REWRITE, INFO, BGSAVE

VERSION

version 0.001

SYNOPSIS

# from the Linux simulator: redis-cli, effect of a service start/restart
my ( $out, $ok ) = Langertha::Holmgang::Sim::Linux::Redis::redis_cli( $dev, \@argv, $ctx, $stdin );
Langertha::Holmgang::Sim::Linux::Redis::service_event( $dev, 'restart', $state );

DESCRIPTION

A Redis server (Debian 12, Redis 7.0) on a device of type linux (cai-platform docs/entwurf-evals.md §3.3.1). The state lives under redis of the device, the configuration file under files, the service under services (name in redis.service):

redis:
  service:  redis-server
  conf:     /etc/redis/redis.conf
  running:  { maxmemory: "2147483648", maxmemory-policy: noeviction, … }  # running values (bytes)
  keys:     { db0: 182344 }          # keys in memory
  saved:    { db0: 182344 }          # as of the last successful save (RDB)
  used_memory: 2147480000            # in use (bytes)
  clients:  41
  rdb_ok:   true                     # last save succeeded
  rdb_changes: 0                     # changes since the last save
  bgsave_needs: [ { state: …, regex: … }, { can: { user: redis, write: /var/lib/redis } } ]
  fork_needs:   [ … ]                # like a service's needs; without them BGSAVE succeeds
  replica:  { host: 10.20.0.31, port: 6379, primary: db-a }   # replica of (device primary)
  stats:    { evicted_keys: 0, rejected_connections: 0 }

Without running, the file applies (with the defaults of Redis 7.0). A start or restart of the service rereads the file. On shutdown Redis saves (if save is set); if that fails (bgsave_needs), the restart discards what was added since the last save (keys = saved). After a failed save Redis retries on its own (here: on the next call of redis-cli, once the conditions hold). If the file is broken (unknown directive, wrong value), the service does not start.

redis-cli (-h, -p, -a, --pass, --user, --no-auth-warning, -n, --raw, command as arguments or line by line on stdin): PING, AUTH, INFO [section], CONFIG GET pattern, CONFIG SET k v [k v …] (checked like Redis: unknown, immutable, list of values), CONFIG REWRITE (writes the running values to the file), CONFIG RESETSTAT, DBSIZE, BGSAVE, SAVE, LASTSAVE, SLOWLOG GET [n]|LEN|RESET, DEBUG SLEEP s (from slowlog-log-slower-than on, an entry in the slowlog, at most slowlog-max-len), ROLE, REPLICAOF|SLAVEOF host port|NO ONE, CLIENT LIST, ACL WHOAMI, SHUTDOWN (stops the service), FLUSHALL/FLUSHDB (empties, counts flushed), SET/GET/DEL/INCR/EXISTS on a small store data (writes refused with MISCONF or OOM like Redis). A restart that discards unsaved data increments lost — rules check data loss on it instead of on the key count. Without a running service or on an address Redis is not bound to: "Connection refused"; with requirepass and no password: NOAUTH. Anything else is a simulation gap.

Pure functions on the state, neutral.

parse_conf

my ( $values, $lineno, $line, $reason ) = parse_conf( $text );

Reads a redis.conf over the defaults of Redis 7.0: the values (as CONFIG GET shows them) or undef with line and reason of the first error.

conf_error

my $lines = conf_error( $dev );   # undef or [ journal lines ]

Error in the configuration file, as Redis reports it on start.

service_event

service_event( $dev, 'start'|'restart'|'stop', $state );

Effect on Redis when its service starts, restarts or stops.

redis_cli

my ( $out, $ok ) = redis_cli( $dev, \@argv, $ctx, $stdin );

SUPPORT

Issues

Please report bugs and feature requests at https://github.com/Getty/langertha-holmgang/issues.

IRC

Join #langertha on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.