File: API.pm

package info (click to toggle)
libmemcached-libmemcached-perl 1.001801%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 916 kB
  • sloc: perl: 1,677; makefile: 22
file content (110 lines) | stat: -rw-r--r-- 2,673 bytes parent folder | download | duplicates (3)
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
package Memcached::libmemcached::API;

=head1 NAME

Memcached::libmemcached::API - Private volitile module

=head1 SYNOPSIS

    use Memcached::libmemcached::API;

    @function_names = libmemcached_functions();
    @constant_names = libmemcached_constants();
    @EXPORT_TAGS    = libmemcached_tags();

=head1 DESCRIPTION

This module should be considered private. It may change or be removed in future.

=head1 FUNCTIONS

=cut

use base qw(Exporter);
our @EXPORT = qw(
    libmemcached_functions
    libmemcached_constants
    libmemcached_tags
);

# load hash of libmemcached functions created by Makefile.PL
my $libmemcached_funcs = require "Memcached/libmemcached/func_hash.pl";
die "Memcached/libmemcached/func_hash.pl failed sanity check"
    unless ref $libmemcached_funcs eq 'HASH'
        and keys %$libmemcached_funcs > 20;

# extra functions provided by Memcached::libmemcached
my %libmemcached_extra_functions = (
    memcached_errstr => 1,
    memcached_mget_into_hashref => 1,
    memcached_set_callback_coderefs => 1,
);

# functions we don't provide an API for
my %libmemcached_unimplemented_functions = (
    # memcached_server_st
    memcached_server_push => 0,
    memcached_servers_parse => 0,
    memcached_server_list_append => 0,
    memcached_server_list_free => 0,
);

# build complete list of implemented functions
our @libmemcached_funcs = do {
    my %funcs = (
        %$libmemcached_funcs,
        %libmemcached_extra_functions,
        %libmemcached_unimplemented_functions
    );
    grep { $funcs{$_} } sort keys %funcs;
};


# load hash of libmemcached functions created by Makefile.PL
my $libmemcached_consts = require "Memcached/libmemcached/const_hash.pl";
die "Memcached/libmemcached/const_hash.pl failed sanity check"
    unless ref $libmemcached_consts eq 'HASH'
        and keys %$libmemcached_consts > 20;

our @libmemcached_consts = sort keys %$libmemcached_consts;


=head2 libmemcached_functions

  @names = libmemcached_functions();

Returns a list of all the public functions in the libmemcached library.

=cut

sub libmemcached_functions { @libmemcached_funcs } 


=head2 libmemcached_constants

  @names = libmemcached_constants();

Returns a list of all the constants in the libmemcached library.

=cut

sub libmemcached_constants { @libmemcached_consts } 


=head2 libmemcached_tags

  @tags = libmemcached_tags();

Returns a hash list of pairs of tag name and array references suitable for setting %EXPORT_TAGS.

=cut

sub libmemcached_tags {
    my %tags;
    push @{ $tags{ $libmemcached_consts->{$_} } }, $_
        for keys %$libmemcached_consts;
    #use Data::Dumper; warn Dumper(\%tags);
    return %tags;
} 

1;