package LasTres::Redis;

use v5.36.0;

use strict;
use warnings;

use feature 'signatures';

use parent 'Mojo::Redis';

use LasTres::Schema;
our $VERSION = $LasTres::Schema::VERSION;

{
    sub new {
        my $self;
        my $class = shift;
        if (!defined $self) {
            $self = $class->SUPER::new(@_);
        }
        return $self;
    }
}

sub prefix {
    return "LasTres::Redis::$VERSION";
}

sub subscribe($self, $topic, $callback) {
    $self->pubsub->listen($topic, sub($self, $message, $topic) {
        $callback->($message, $topic, [$topic]);
    });
}

sub publish($self, $topic, $message) {
    $self->pubsub->notify($topic, $message);
}

sub pj_subscription($class, $pj) {
    return prefix() . '::Subscriptions::PJ::' . $pj->uuid;
}
sub executing_frame_key($class) {
    return prefix() . '::Key::Frame';
}
1;
