| 1 | package WebService::Cache::AbstractCacheManager; | ||
| 2 | use strict; | ||
| 3 | use Digest::MD5 qw(md5_hex); | ||
| 4 | use base qw(Class::Data::Inheritable Class::Accessor); | ||
| 5 | __PACKAGE__->mk_classdata('lifetime'=>81600); | ||
| 6 | |||
| 7 | sub new{ | ||
| 8 | my $class = shift; | ||
| 9 | my $self = $class->SUPER::new(); | ||
| 10 | $self->init(@_); | ||
| 11 | return $self; | ||
| 12 | } | ||
| 13 | |||
| 14 | sub init{ | ||
| 15 | my $self = shift; | ||
| 16 | my %args = @_; | ||
| 17 | if(exists $args{'lifetime'}){ | ||
| 18 | $self->lifetime($args{'lifetime'}); | ||
| 19 | } | ||
| 20 | } | ||
| 21 | |||
| 22 | sub store_cache{ | ||
| 23 | my $self = shift; | ||
| 24 | my $id = shift; | ||
| 25 | my $result = shift; | ||
| 26 | } | ||
| 27 | |||
| 28 | sub retrieve_cache{ | ||
| 29 | my $self = shift; | ||
| 30 | my $id = shift; | ||
| 31 | } | ||
| 32 | |||
| 33 | sub is_cached{ | ||
| 34 | my $self = shift; | ||
| 35 | my $id = shift; | ||
| 36 | return 0; | ||
| 37 | } | ||
| 38 | |||
| 39 | sub create_cache_id{ | ||
| 40 | my $self = shift; | ||
| 41 | my $id; | ||
| 42 | foreach my $arg (sort {$a <=>$b} @_){ | ||
| 43 | if(ref $arg eq "HASH"){ | ||
| 44 | $id .= join ':',sort {$a <=> $b} values %{$arg}; | ||
| 45 | } | ||
| 46 | else{ | ||
| 47 | $id .=$arg; | ||
| 48 | } | ||
| 49 | } | ||
| 50 | return md5_hex($id); | ||
| 51 | } | ||
| 52 | |||
| 53 | 1; |