pevensie/redis
Types
Configuration for connecting to a Redis-compatible database.
Use the default_config
function to get a default configuration
for connecting to a local Redis database with sensible defaults.
pub type RedisConfig {
RedisConfig(
host: String,
port: Int,
timeout: Int,
pool_size: Int,
username: Option(String),
password: Option(String),
)
}
Constructors
-
RedisConfig( host: String, port: Int, timeout: Int, pool_size: Int, username: Option(String), password: Option(String), )
Errors that can occur when interacting with the Postgres driver.
pub type RedisError {
StartError(bath.StartError(actor.StartError))
ActorError
ConnectionError
TCPError(mug.Error)
ServerError(String)
ShutdownError(bath.ShutdownError)
PoolError(bath.ApplyError(actor.StartError))
UnknownResponseError
}
Constructors
-
StartError(bath.StartError(actor.StartError))
The connection pool failed to start.
-
ActorError
An error occurred in the underlying OTP actor.
-
ConnectionError
There was an error connecting to the database.
-
TCPError(mug.Error)
A TCP error occurred.
-
ServerError(String)
An error occurred on the server.
-
ShutdownError(bath.ShutdownError)
There was an error shutting down the connection pool.
-
PoolError(bath.ApplyError(actor.StartError))
There was an error applying a function to the connection pool.
-
UnknownResponseError
An unknown response was received from the server.
Functions
pub fn default_config() -> RedisConfig
Returns a default RedisConfig
for connecting to a local Redis
database with sensible defaults.
pub fn new_cache_driver(
config: RedisConfig,
) -> CacheDriver(Redis, RedisError)
Creates a new CacheDriver
for use with
the pevensie/cache.new
function.
import pevensie/redis.{type RedisConfig}
import pevensie/cache
pub fn main() {
let config = RedisConfig(
..redis.default_config(),
host: "cache.pevensie.dev",
)
let driver = redis.new_cache_driver(config)
let pevensie_auth = cache.new(driver:)
// ...
}