File: cache.plm

package info (click to toggle)
plum 1%3A2.33.1-13
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,056 kB
  • sloc: perl: 4,453; makefile: 2
file content (131 lines) | stat: -rw-r--r-- 3,438 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# $Id: cache.plm,v 2.5 1999/01/31 10:07:05 hasegawa Exp $
# copyright (c)1999 Yoshinori Hasegawa <hasegawa@madoka.org>

package auto_cache;

$SIZE = 10;
$EXPIRE = 600;

$_ = 'auto_cache';

sub module_disable {
  local($userno) = @_;
  local($no, $chan);
  foreach $key (keys(%cache)) {
    ($no, $chan) = split(/$;/, $key, 2);
    next unless $'userno[$no] == $userno;
    delete $cache{$key};
  }
}

sub server_close {
  local($serverno) = @_;
  local($no, $chan);
  foreach $key (keys(%cache)) {
    ($no, $chan) = split(/$;/, $key, 2);
    next unless $no == $serverno;
    delete $cache{$key};
  }
}

sub ss_privmsg {
  local($serverno, $prefix, $cmd, @params) = @_;
  local($regex);
  if (&'channel($params[0])) {
    foreach $clear (&'property($'userno[$serverno], 'clear')) {
      $regex = &'regex(&'jis_euc($clear));
      next unless &'jis_euc($params[1]) =~ /$regex/;
      $cache{$serverno, $params[0]} = '';
      last;
    }
  }
  return ($prefix, $cmd, @params);
}

sub sp_privmsg {
  local($serverno, $prefix, $cmd, @params) = @_;
  local(@list, $size, $key, $expire, $now, $time, $text);
  if (&'channel($params[0])) {
    $size = &'property($'userno[$serverno], 'size');
    $size = $SIZE unless defined($size);
    $key = $serverno . $; . $params[0];
    @list = &'array($cache{$key});
    while (@list > $size) {
      shift(@list);
    }
    $expire = &'property($'userno[$serverno], 'expire');
    $expire = $EXPIRE unless defined($expire);
    $now = time();
    foreach $line (@list) {
      ($time, $text) = split(/\:/, $line, 2);
      next if ($expire != 0 && $time + $expire < $now);
      return () if $text eq $params[1];
    }
    $cache{$key} = '' unless $cache{$key};
    $cache{$key} .= &'list($now . ':' . $params[1]);
  }
  return ($prefix, $cmd, @params);
}

sub ss_part {
  local($serverno, $prefix, $cmd, @params) = @_;
  delete $cache{$serverno, $params[0]};
  return ($prefix, $cmd, @params);
}

__END__
--><HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-2022-JP">
<LINK REV="made" HREF="mailto:hasegawa@madoka.org">
<TITLE>auto/cache.plm</TITLE></HEAD><BODY>

$B%*%s%i%$%s%I%-%e%a%s%H(B


<HR><H3>$BL>A0(B</H3>

auto/cache.plm - $BF1$8H/8@$r7+$jJV$5$J$$$h$&$K@)8B$9$k(B


<HR><H3>$B@bL@(B</H3>

$B2a5n$KH/8@$7$?J8;zNs$rJ]B8$7$F$*$-!"$=$NCf$KH/8@$7$h$&$H$7$F$$$k(B
$BJ8;zNs$,$"$l$P!"$=$l$rH/8@$7$J$$$h$&$K$7$^$9!#(B


<HR><H3>$B%W%m%Q%F%#(B</H3>

<DL>
<DT>  auto.cache.size $B%-%c%C%7%e$NBg$-$5(B
</DT>
<DD>    $BJ]B8$7$F$*$/H/8@?t$N?t$r;XDj$7$^$9!#(B
        $B%G%U%)%k%H$G$O(B10$B$K$J$C$F$$$^$9!#(B
</DD>
<DT>  auto.cache.expire $B%-%c%C%7%e$NM-8z4|8B(B
</DT>
<DD>    $B%-%c%C%7%e$,M-8z$J;~4V$r;XDj$7$^$9!#(B
        $B$3$3$G;XDj$7$?IC?t$,7P2a$7$?%-%c%C%7%e$O<+F0E*$K%/%j%"$5$l$^$9!#(B
        0$B$r;XDj$9$k$H!"%/%j%"$O9T$o$l$^$;$s!#(B
        $B%G%U%)%k%H$G$O(B600$B$K$J$C$F$$$^$9!#(B
</DD>
<DT>  auto.cache.clear* $B%-%c%C%7%e$r%/%j%"$9$kH/8@(B
</DT>
<DD>    $B$3$3$G;XDj$7$?J8;zNs$rH/8@$9$k$H!"%-%c%C%7%e$r%/%j%"$7$^$9!#(B
</DD>
</DL>


<HR><H3>$B@_DjNc(B</H3>

<PRE>
+ auto/cache.plm
auto.cache.size: 5
auto.cache.expire: 300
auto.cache.clear: $B$W$i$`$7$g$-$+(B
</PRE>

$B2a5n$NH/8@$r(B5$B$D$^$GJ]B8$7$F$*$-!"$=$l$HF1$8H/8@$r$7$J$$$h$&$K$7$^$9!#(B
$B!V$W$i$`$7$g$-$+!W$HH/8@$9$k$H!"$=$N%A%c%s%M%k$N%-%c%C%7%e$r%/%j%"$7$^$9!#(B
$B$^$?!"(B300$BIC$,7P2a$7$?%-%c%C%7%e$b<+F0E*$K%/%j%"$5$l$^$9!#(B

</BODY></HTML>