File Coverage

blib/lib/Cache/Object.pm
Criterion Covered Total %
statement 30 38 78.9
branch n/a
condition 1 3 33.3
subroutine 13 16 81.2
pod 1 15 6.7
total 45 72 62.5


line stmt bran cond sub pod time code
1             ######################################################################
2             # $Id: Object.pm,v 1.9 2003/04/15 14:46:23 dclinton Exp $
3             # Copyright (C) 2001-2003 DeWitt Clinton All Rights Reserved
4             #
5             # Software distributed under the License is distributed on an "AS
6             # IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or
7             # implied. See the License for the specific language governing
8             # rights and limitations under the License.
9             ######################################################################
10              
11             package Cache::Object;
12              
13 4     4   65 use strict;
  4         67  
  4         58  
14              
15              
16             sub new
17             {
18 126     126 1 1305   my ( $proto ) = @_;
19 126   33     1622   my $class = ref( $proto ) || $proto;
20 126         3531   my $self = {};
21 126         1467   bless ( $self, $class );
22 126         1824   return $self;
23             }
24              
25              
26             sub get_created_at
27             {
28 0     0 0 0   my ( $self ) = @_;
29              
30 0         0   return $self->{_Created_At};
31             }
32              
33             sub set_created_at
34             {
35 126     126 0 1673   my ( $self, $p_created_at ) = @_;
36              
37 126         1645   $self->{_Created_At} = $p_created_at;
38             }
39              
40              
41             sub get_accessed_at
42             {
43 20     20 0 245   my ( $self ) = @_;
44              
45 20         256   return $self->{_Accessed_At};
46             }
47              
48             sub set_accessed_at
49             {
50 172     172 0 5905   my ( $self, $p_accessed_at ) = @_;
51              
52 172         1990   $self->{_Accessed_At} = $p_accessed_at;
53             }
54              
55              
56             sub get_data
57             {
58 50     50 0 425   my ( $self ) = @_;
59              
60 50         2048   return $self->{_Data};
61             }
62              
63             sub set_data
64             {
65 126     126 0 1167   my ( $self, $p_data ) = @_;
66              
67 126         1512   $self->{_Data} = $p_data;
68             }
69              
70              
71             sub get_expires_at
72             {
73 344     344 0 4073   my ( $self ) = @_;
74              
75 344         5778   return $self->{_Expires_At};
76             }
77              
78              
79             sub set_expires_at
80             {
81 126     126 0 1254   my ( $self, $p_expires_at ) = @_;
82              
83 126         1636   $self->{_Expires_At} = $p_expires_at;
84             }
85              
86              
87             sub get_key
88             {
89 60     60 0 497   my ( $self ) = @_;
90              
91 60         854   return $self->{_Key};
92             }
93              
94              
95             sub set_key
96             {
97 480     480 0 7795   my ( $self, $p_key ) = @_;
98              
99 480         8776   $self->{_Key} = $p_key;
100             }
101              
102              
103              
104             sub get_size
105             {
106 40     40 0 334   my ( $self ) = @_;
107              
108 40         2230   return $self->{_Size};
109             }
110              
111              
112             sub set_size
113             {
114 354     354 0 3647   my ( $self, $p_size ) = @_;
115              
116 354         4604   $self->{_Size} = $p_size;
117             }
118              
119              
120             sub get_identifier
121             {
122 0     0 0     my ( $self ) = @_;
123              
124 0             warn( "get_identifier has been marked deprepricated. use get_key" );
125              
126 0             return $self->get_key( );
127             }
128              
129              
130             sub set_identifier
131             {
132 0     0 0     my ( $self, $p_identifier ) = @_;
133              
134 0             warn( "set_identifier has been marked deprepricated. use set_key" );
135              
136 0             return $self->set_key( $p_identifier );
137             }
138              
139              
140              
141              
142             1;
143              
144              
145             __END__
146            
147             =pod
148            
149             =head1 NAME
150            
151             Cache::Object -- the data stored in a Cache.
152            
153             =head1 DESCRIPTION
154            
155             Object is used by classes implementing the Cache interface as an
156             object oriented wrapper around the data. End users will not normally
157             use Object directly, but it can be retrieved via the get_object method
158             on the Cache::Cache interface.
159            
160             =head1 SYNOPSIS
161            
162             use Cache::Object;
163            
164             my $object = new Cache::Object( );
165            
166             $object->set_key( $key );
167             $object->set_data( $data );
168             $object->set_expires_at( $expires_at );
169             $object->set_created_at( $created_at );
170            
171            
172             =head1 METHODS
173            
174             =over
175            
176             =item B<new( )>
177            
178             Construct a new Cache::Object.
179            
180             =back
181            
182             =head1 PROPERTIES
183            
184             =over
185            
186             =item B<(get|set)_accessed_at>
187            
188             The time at which the object was last accessed. Various cache
189             implementations will use the accessed_at property to store information
190             for LRU algorithms. There is no guarentee that all caches will update
191             this field, however.
192            
193             =item B<(get|set)_created_at>
194            
195             The time at which the object was created.
196            
197             =item B<(get|set)_data>
198            
199             A scalar containing or a reference pointing to the data to be stored.
200            
201             =item B<(get|set)_expires_at>
202            
203             The time at which the object should expire from the cache.
204            
205             =item B<(get|set)_key>
206            
207             The key under which the object was stored.
208            
209             =item B<(get|set)_size>
210            
211             The size of the frozen version of this object
212            
213             =back
214            
215             =head1 SEE ALSO
216            
217             Cache::Cache
218            
219             =head1 AUTHOR
220            
221             Original author: DeWitt Clinton <dewitt@unto.net>
222            
223             Last author: $Author: dclinton $
224            
225             Copyright (C) 2001-2003 DeWitt Clinton
226            
227             =cut
228            
229