summaryrefslogtreecommitdiff
path: root/fml/lib/FML
diff options
context:
space:
mode:
authorfukachan <fukachan>2004-05-25 03:33:29 +0000
committerfukachan <fukachan>2004-05-25 03:33:29 +0000
commitc5ed2014bb28ce5ca609126910ef479cab47669f (patch)
tree96b0d9238511f04b97781b911465556a0a1693ac /fml/lib/FML
parent095f24336d4d25a2893e4ae34398faff0868f18c (diff)
downloadfml8-c5ed2014bb28ce5ca609126910ef479cab47669f.tar.gz
fml8-c5ed2014bb28ce5ca609126910ef479cab47669f.tar.bz2
fml8-c5ed2014bb28ce5ca609126910ef479cab47669f.zip
import data from file directly.
Actually, link(2) $src to cache file.
Diffstat (limited to 'fml/lib/FML')
-rw-r--r--fml/lib/FML/Cache/Ring.pm47
1 files changed, 46 insertions, 1 deletions
diff --git a/fml/lib/FML/Cache/Ring.pm b/fml/lib/FML/Cache/Ring.pm
index 3c4a2e7b..76fae052 100644
--- a/fml/lib/FML/Cache/Ring.pm
+++ b/fml/lib/FML/Cache/Ring.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: CacheDir.pm,v 1.27 2004/04/15 11:33:03 fukachan Exp $
+# $FML: Ring.pm,v 1.1 2004/04/17 06:18:05 fukachan Exp $
#
package FML::Cache::Ring;
@@ -249,6 +249,51 @@ sub close
}
+=head2 import_data_from($args)
+
+import data from file.
+Actually, link(2) $src to cache file.
+
+ KEY VALUE
+ ---------------------------
+ file STR
+ try_link STR ( yes | no )
+
+=cut
+
+
+# Descriptions: import data from file.
+# Arguments: OBJ($self) HASH_REF($args)
+# Side Effects: create $dst file (linked).
+# Return Value: NUM(1(success) or 0(fail))
+sub import_data_from
+{
+ my ($self, $args) = @_;
+ my $link = $args->{ try_link } || 1;
+ my $src = $args->{ file } || '';
+ my $dst = $self->cache_file_path() || '';
+
+ unless ($src) { return 0;}
+ unless ($dst) {
+ $self->open();
+ $dst = $self->cache_file_path() || '';
+ }
+
+ if ($dst && $src) {
+ return 0 unless -f $src;
+ unlink $dst if -f $dst;
+ if (link($src, $dst)) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
+ }
+
+ return 0;
+}
+
+
=head2 get(key)
get value (latest value in the ring buffer) for key.