|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/fatshado/cgi-bin/MT/lib/MT/ |
Upload File : |
# Copyright 2001, 2002 Benjamin Trott. This code cannot be redistributed without
# permission from www.movabletype.org.
#
# $Id: Request.pm,v 1.2 2002/02/01 00:36:34 btrott Exp $
package MT::Request;
use strict;
use MT::ErrorHandler;
@MT::Request::ISA = qw( MT::ErrorHandler );
use vars qw( $r );
sub instance {
return $r if $r;
$r = __PACKAGE__->new;
}
sub new {
my $req = bless { __stash => { } }, $_[0];
$req;
}
sub stash {
my $req = shift;
my $key = shift;
$req->{__stash}->{$key} = shift if @_;
$req->{__stash}->{$key};
}
*cache = \&stash;
1;
__END__
=head1 NAME
MT::Request - Movable Type request cache
=head1 SYNOPSIS
use MT::Request;
my $r = MT::Request->instance;
$r->cache('foo', $foo);
## Later and elsewhere...
my $foo = $r->cache('foo');
=head1 DESCRIPTION
I<MT::Request> is a very simple singleton object which lasts only for one
particular request to the application, and thus can be used for caching data
that you would like to disappear after the application request exists (and not
for the lifetime of the application).
=head1 USAGE
=head2 MT::Request->instance
Returns the I<MT::Request> singleton.
=head2 $r->cache($key [, $value ])
Given a key I<$key>, returns the cached value of the key in the cache held by
the object I<$r>. Given a value I<$value> and a key I<$key>, sets the value of
the key I<$key> in the cache. I<$value> can be a simple scalar, a reference,
an object, etc.
=head1 AUTHOR & COPYRIGHT
Please see the I<MT> manpage for author, copyright, and license information.
=cut