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

Cache::Reddit - a caching API that uses Reddit as the backend

VERSION

version 0.04

SYNOPSIS

use Cache::Reddit;

my $id = set($data_ref);  # serialize data and post to subreddit
my $data = get($id);      # retrieve the data back
remove($id);              # delete the data from Reddit

DESCRIPTION

Cache::Reddit is a module for cacheing your application data on Reddit. Data is serialized using Storable and posted to a subreddit. The data is posted as a text post, and the title of the post set to Cache::Reddit:: + a random number.

The text is bleached before posting (converted to binary, tr/01/ \t/g) so it appears as whitespace on Reddit.

Due to the list-like search function, data retrieval performs at 0(n). However deletion and insertion performs at 0(1).

It requires three environment variables to be set:

  • reddit_username - the reddit username to login with

  • reddit_password - the reddit password to login with

  • reddit_subreddit - the target subreddit to post data to

EXPORTED FUNCTIONS

set($dataref)

Serializes and saves the data in the subreddit as a text post. Returns the key for cached entry;

get ($key)

Deserializes and returns the cached entry.

remove ($key)

Deletes the item from the subreddit.

AUTHOR

David Farrell <dfarrell@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by David Farrell.

This is free software, licensed under:

The (two-clause) FreeBSD License