summaryrefslogtreecommitdiff
path: root/fml/lib
diff options
context:
space:
mode:
authorfukachan <fukachan>2006-10-08 10:07:43 +0000
committerfukachan <fukachan>2006-10-08 10:07:43 +0000
commitdafcd9562a72ef07e3058e5e6348ffa2429d7ff7 (patch)
treee934a3da1d4601ef3396d47c23924a1fc562f736 /fml/lib
parent8aaf68a8459c9ae4e54e567fb39db1a41965bad2 (diff)
downloadfml8-dafcd9562a72ef07e3058e5e6348ffa2429d7ff7.tar.gz
fml8-dafcd9562a72ef07e3058e5e6348ffa2429d7ff7.tar.bz2
fml8-dafcd9562a72ef07e3058e5e6348ffa2429d7ff7.zip
not used
Diffstat (limited to 'fml/lib')
-rw-r--r--fml/lib/FML/Data/Deadline.pm203
1 files changed, 0 insertions, 203 deletions
diff --git a/fml/lib/FML/Data/Deadline.pm b/fml/lib/FML/Data/Deadline.pm
deleted file mode 100644
index fa1a6ff6..00000000
--- a/fml/lib/FML/Data/Deadline.pm
+++ /dev/null
@@ -1,203 +0,0 @@
-#-*- perl -*-
-#
-# Copyright (C) 2003 Ken'ichi Fukamachi
-# All rights reserved. This program is free software; you can
-# redistribute it and/or modify it under the same terms as Perl itself.
-#
-# $FML: Deadline.pm,v 1.1 2003/11/22 05:41:52 fukachan Exp $
-#
-
-package FML::Data::Deadline;
-use strict;
-use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
-use Carp;
-
-=head1 NAME
-
-FML::Data::Deadline - maintain data with expiration.
-
-=head1 SYNOPSIS
-
-=head1 DESCRIPTION
-
-=head1 METHODS
-
-=head2 C<new()>
-
-=cut
-
-
-# Descriptions: constructor.
-# Arguments: OBJ($self) OBJ($curproc) HASH_REF($cargs)
-# Side Effects: create object
-# Return Value: OBJ
-sub new
-{
- my ($self, $curproc, $cargs) = @_;
- my ($type) = ref($self) || $self;
- my $me = { _curproc => $curproc };
-
- for my $id ('keyword', 'class', 'address', 'buffer', 'cache_dir') {
- if (defined $cargs->{ $id }) {
- $me->{ "_$id" } = $cargs->{ $id };
- }
- }
-
- use FML::Cache::Journal;
- $me->{ _journal_db } = new FML::Cache::Journal $curproc;
-
- return bless $me, $type;
-}
-
-
-=head2 add($key, $value)
-
-=cut
-
-
-# Descriptions: add { $key => $value }.
-# Arguments: OBJ($self) STR($key) STR($value)
-# Side Effects: update database
-# Return Value: none
-sub add
-{
- my ($self, $key, $value) = @_;
- my $class = $self->{ _class };
- my $addr = $self->{ _address };
-
- # update database.
- my $db = $self->_open_db();
- $db->{ $key } = sprintf("%s submitted_time=%s", $value, time);
- $self->_close_db();
-}
-
-
-=head2 find($key)
-
-find value for $key not expired yet.
-
-=cut
-
-
-# Descriptions: find value for $key
-# Arguments: OBJ($self) STR($key)
-# Side Effects: none
-# Return Value: STR
-sub find
-{
- my ($self, $key) = @_;
-
- if ($self->is_expired($key)) {
- return '';
- }
- else {
- # search
- my $db = $self->_open_db();
- my $found = $db->{ $key } || '';
- $self->_close_db();
-
- ($found) = split(/\s+/, $found);
- return( $found || '' );
- }
-}
-
-
-=head2 is_expired($key)
-
-check if $key is is_expired.
-
-=cut
-
-
-# Descriptions: check if $key is is_expired
-# Arguments: OBJ($self) STR($key)
-# Side Effects: none
-# Return Value: NUM(1 or 0)
-sub is_expired
-{
- my ($self, $key) = @_;
- my $now = time;
-
- # get value
- my $db = $self->_open_db();
- my $found = $db->{ $key } || '';
- $self->_close_db();
-
- my ($xkey, $time) = split(/\s+/, $found);
- if ($time > $now) {
- return 1;
- }
- else {
- return 0;
- }
-}
-
-
-=head1 Cache database
-
-This cache uses C<FML::Cache::Journal> based on C<Tie::JournaledDir>.
-
-=head2 _open_db()
-
-=head2 _close_db()
-
-=cut
-
-
-# Descriptions: open cache database.
-# Arguments: OBJ($self)
-# Side Effects: close db
-# Return Value: HASH_REF
-sub _open_db
-{
- my ($self) = @_;
- my $db = $self->{ _journal_db };
- my $dir = $self->{ _cache_dir };
- my $class = $self->{ _class };
-
- if (defined $db) {
- my $_db = $db->open($dir, $class);
- $self->{ _db } = $_db;
- return $_db;
- }
-}
-
-
-# Descriptions: close database interface.
-# Arguments: OBJ($self)
-# Side Effects: close db
-# Return Value: none
-sub _close_db
-{
- my ($self) = @_;
- my $db = $self->{ _journal_db };
- if (defined $db) {
- $db->close();
- }
-}
-
-
-=head1 CODING STYLE
-
-See C<http://www.fml.org/software/FNF/> on fml coding style guide.
-
-=head1 AUTHOR
-
-Ken'ichi Fukamachi
-
-=head1 COPYRIGHT
-
-Copyright (C) 2003 Ken'ichi Fukamachi
-
-All rights reserved. This program is free software; you can
-redistribute it and/or modify it under the same terms as Perl itself.
-
-=head1 HISTORY
-
-FML::Data::Deadline appeared in fml8 mailing list driver package.
-See C<http://www.fml.org/> for more details.
-
-=cut
-
-
-1;