This file is indexed.

/usr/share/perl5/Mojo/Cache.pm is in libmojolicious-perl 6.15+dfsg-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
package Mojo::Cache;
use Mojo::Base -base;

has 'max_keys' => 100;

sub get { (shift->{cache} || {})->{shift()} }

sub set {
  my ($self, $key, $value) = @_;

  return $self unless (my $max = $self->max_keys) > 0;

  my $cache = $self->{cache} ||= {};
  my $queue = $self->{queue} ||= [];
  delete $cache->{shift @$queue} while @$queue >= $max;
  push @$queue, $key unless exists $cache->{$key};
  $cache->{$key} = $value;

  return $self;
}

1;

=encoding utf8

=head1 NAME

Mojo::Cache - Naive in-memory cache

=head1 SYNOPSIS

  use Mojo::Cache;

  my $cache = Mojo::Cache->new(max_keys => 50);
  $cache->set(foo => 'bar');
  my $foo = $cache->get('foo');

=head1 DESCRIPTION

L<Mojo::Cache> is a naive in-memory cache with size limits.

=head1 ATTRIBUTES

L<Mojo::Cache> implements the following attributes.

=head2 max_keys

  my $max = $cache->max_keys;
  $cache  = $cache->max_keys(50);

Maximum number of cache keys, defaults to C<100>. Setting the value to C<0>
will disable caching.

=head1 METHODS

L<Mojo::Cache> inherits all methods from L<Mojo::Base> and implements the
following new ones.

=head2 get

  my $value = $cache->get('foo');

Get cached value.

=head2 set

  $cache = $cache->set(foo => 'bar');

Set cached value.

=head1 SEE ALSO

L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.

=cut