URI::redis(3)

πŸ“¦ version 0.02, in alpine 3.24

πŸ’– URI::redis(3) β€” URI for Redis connection info πŸ’–

okay bestie, welcome to the URI::redis manual page πŸ’… this is User Contributed Perl Documentation, and it’s literally here to explain the URI class for Redis connection info. no cap, it’s giving very specific but very useful ✨

✨ NAME ✨

URI::redis β€” URI for Redis connection info 🫢

πŸš€ SYNOPSIS πŸš€

use URI::redis;

$url = URI->new('redis://redis.example.com?password=correcthorsebatterystaple');

$url = URI->new('redis://redis.example.com?db=5&password=correcthorsebatterystaple');

$url = URI->new('redis+unix:///tmp/redis.sock?db=5&password=correcthorsebatterystaple');

πŸ’… DESCRIPTION πŸ’…

The URI::redis class supports URI objects belonging to the redis and redis+unix URI scheme. 🌸

Those URLs are used to encode connection info to Redis servers β€” for redis that’s host, port, password, database, and for redis+unix that’s socket path, password, database. iconic, honestly πŸ‘‘

Supported URLs are in any of these formats:

The TCP connection crew β€” and yes, the port defaults to 6379 and the host defaults to "localhost" β€” see <http://www.iana.org/assignments/uri-schemes/prov/redis>:

  • "redis://HOST[:PORT][?db=DATABASE[&password=PASSWORD]]"
  • "redis://HOST[:PORT][?password=PASSWORD[&db=DATABASE]]"
  • "redis://[:PASSWORD@]HOST[:PORT][/DATABASE]"
  • "redis://[:PASSWORD@]HOST[:PORT][?db=DATABASE]"
  • "redis://HOST[:PORT]/DATABASE[?password=PASSWORD]"

The Unix domain socket crew 🐬

  • "redis+unix://[:PASSWORD@]SOCKET_PATH[?db=DATABASE]"
  • "redis+unix://SOCKET_PATH[?db=DATABASE[&password=PASSWORD]]"
  • "redis+unix://SOCKET_PATH[?password=PASSWORD[&db=DATABASE]]"

A Unix domain socket connection. πŸ¦‹

πŸ› οΈ METHODS πŸ› οΈ

In addition to the methods inherited from URI, it provides the following methods:

πŸ—„οΈ database πŸ—„οΈ

Returns the database number from the path or the db query param.

Returns 0 if no database is specified. ✨

🧚 database_from_path 🧚

Returns the database number encoded in the path part of the URI. Only works if the path is in the format "^ / \d+".

Returns undef if no database can be parsed from the path.

πŸ”Ž database_from_query πŸ”Ž

Returns the database number from the db query param.

Returns undef if no db query param, or it has no value set.

πŸ” password πŸ”

Returns the password from the userinfo or the password query param.

🫢 password_from_userinfo 🫢

Returns the password part of the userinfo in URI.

πŸ“ password_from_query πŸ“

Returns the password from the password query param.

🧦 socket_path 🧦

Returns the Unix domain socket path.

Returns undef if the URI is not of the 'redis+unix' scheme.

πŸ‘€ SEE ALSO πŸ‘€

URI β€” the whole reason this class can inherit all its main-character energy πŸ’œ

Copyright 2016 Norbert Buchmueller.

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


πŸ’– and that’s the page, bestie β€” brought to you by perl v5.42.2, dated 2026-02-15, filed under URI::redis(3). slay ✨

πŸ“¦ where this page comes from