The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Myriad::Role::Storage - microservice storage abstraction

SYNOPSIS

 my $storage = $myriad->storage;
 await $storage->get('some_key');
 await $storage->hash_add('some_key', 'hash_key', 13);

DESCRIPTION

Provides an abstraction over the Redis-based data model used by Myriad services.

For more information on the API design, please see the official Redis commands list. This model was used as the basis for the methods even when non-Redis backend storage systems are used.

Implementation

Note that this is defined as a rôle, so it does not provide a concrete implementation - instead, see classes such as:

METHODS - Write

set

Takes the following parameters:

  • $k - the relative key in storage

  • $v - the scalar value to set

Note that references are currently not supported - attempts to write an arrayref, hashref or object will fail.

Returns a Future which will resolve on completion.

getset

Performs the same operation as "set", but additionally returns the original key value, if any.

Takes the following parameters:

  • $k - the relative key in storage

  • $v - the scalar value to set

Note that references are currently not supported - attempts to write an arrayref, hashref or object will fail.

Returns a Future which will resolve on completion to the original value, or undef if none.

push

Takes the following parameters:

  • $k - the relative key in storage

  • $v - the scalar value to set

Returns a Future.

unshift

Takes the following parameters:

Returns a Future.

pop

Returns a Future which will resolve to the item removed from the list, or undef if none available.

shift

Returns a Future which will resolve to the item removed from the list, or undef if none available.

hash_set

Takes the following parameters:

Returns a Future which will resolve to .

hash_add

Takes the following parameters:

Returns a Future indicating success or failure.

orderedset_add

Adds a member to an orderedset structure Takes the following parameters:

  • $k - the relative key in storage

  • $s - the scalar value of the score attached to member

  • $m - the scalar value of member

Returns a Future.

orderedset_remove_memeber

Removes a member from an orderedset structure Takes the following parameters:

  • $k - the relative key in storage

  • $m - the scalar value of member

Returns a Future.

orderedset_remove_byscore

Removes members that have scores within the range passed from an orderedset structure Takes the following parameters:

  • $k - the relative key in storage

  • $min - the value of minimum score

  • $max - the value of maximum score

Returns a Future.

METHODS - Read

get

Takes the following parameters:

  • $k - the relative key in storage

Returns a Future which will resolve to the corresponding value, or undef if none.

observe

Observe a specific key.

Returns a Ryu::Observable which will emit the current and all subsequent values.

hash_get

Takes the following parameters:

Returns a Future which will resolve to the scalar value for this key.

hash_keys

Takes the following parameters:

Returns a Future which will resolve to a list of the keys in no defined order.

hash_values

Takes the following parameters:

Returns a Future which will resolve to a list of the values in no defined order.

hash_exists

Takes the following parameters:

Returns a Future which will resolve to true if the key exists in this hash.

hash_count

Takes the following parameters:

Returns a Future which will resolve to the count of the keys in this hash.

hash_as_list

Takes the following parameters:

Returns a Future which will resolve to a list of key/value pairs, suitable for assigning to a hash.

orderedset_member_count

Returns the count of members that have scores within the range passed from an orderedset structure Takes the following parameters:

  • $k - the relative key in storage

  • $min - the value of minimum score

  • $max - the value of maximum score

Returns a Future.

orderedset_members

Returns the members that have scores within the range passed from an orderedset structure Takes the following parameters:

  • $k - the relative key in storage

  • $min - the value of minimum score

  • $max - the value of maximum score

Returns a Future.

INHERITED METHODS

Object::Pad::UNIVERSAL

BUILDARGS

AUTHOR

Deriv Group Services Ltd. DERIV@cpan.org.

See "CONTRIBUTORS" in Myriad for full details.

LICENSE

Copyright Deriv Group Services Ltd 2020-2022. Licensed under the same terms as Perl itself.