View | Details | Raw Unified | Return to bug 10503
Collapse All | Expand All

(-)a/C4/Biblio.pm (-1 / +1 lines)
Lines 146-152 eval { Link Here
146
        import Memoize::Memcached qw(memoize_memcached);
146
        import Memoize::Memcached qw(memoize_memcached);
147
147
148
        memoize_memcached( 'GetMarcStructure',
148
        memoize_memcached( 'GetMarcStructure',
149
                            memcached => C4::Context->memcached);
149
                            memcached => C4::Context->memcached_params);
150
    }
150
    }
151
};
151
};
152
152
(-)a/C4/Context.pm (-13 / +27 lines)
Lines 18-24 package C4::Context; Link Here
18
18
19
use strict;
19
use strict;
20
use warnings;
20
use warnings;
21
use vars qw($VERSION $AUTOLOAD $context @context_stack $servers $memcached $ismemcached);
21
use vars qw($VERSION $AUTOLOAD $context @context_stack $memcached $ismemcached);
22
22
23
BEGIN {
23
BEGIN {
24
	if ($ENV{'HTTP_USER_AGENT'})	{
24
	if ($ENV{'HTTP_USER_AGENT'})	{
Lines 79-101 BEGIN { Link Here
79
		}
79
		}
80
    }  	# else there is no browser to send fatals to!
80
    }  	# else there is no browser to send fatals to!
81
81
82
    $VERSION = '3.07.00.049';
83
}
84
85
UNITCHECK {
82
    # Check if there are memcached servers set
86
    # Check if there are memcached servers set
83
    $servers = $ENV{'MEMCACHED_SERVERS'};
87
    if ($ENV{'MEMCACHED_SERVERS'}) {
84
    if ($servers) {
85
        # Load required libraries and create the memcached object
88
        # Load required libraries and create the memcached object
86
        require Cache::Memcached;
89
        require Cache::Memcached;
87
        $memcached = Cache::Memcached->new({
90
        $memcached = Cache::Memcached->new(memcached_params());
88
        servers => [ $servers ],
89
        debug   => 0,
90
        compress_threshold => 10_000,
91
        expire_time => 600,
92
        namespace => $ENV{'MEMCACHED_NAMESPACE'} || 'koha'
93
    });
94
        # Verify memcached available (set a variable and test the output)
91
        # Verify memcached available (set a variable and test the output)
95
    $ismemcached = $memcached->set('ismemcached','1');
92
        $ismemcached = $memcached->set('ismemcached','1');
96
    }
93
    }
97
98
    $VERSION = '3.07.00.049';
99
}
94
}
100
95
101
use DBI;
96
use DBI;
Lines 293-298 sub memcached { Link Here
293
    }
288
    }
294
}
289
}
295
290
291
=head2 memcached_params
292
293
Return a hashref containing the memcached parameters in a
294
form suitable for initializing a new C<Cache::Memcached>
295
object. Caller is responsible for verifying that connection
296
parameters work.
297
298
=cut
299
300
sub memcached_params {
301
    return {
302
        servers            => [ $ENV{'MEMCACHED_SERVERS'} ],
303
        namespace          => $ENV{'MEMCACHED_NAMESPACE'} || 'koha',
304
        debug              => 0,
305
        expire_time        => 600,
306
        compress_threshold => 10_000,
307
    };
308
}
309
296
# db_scheme2dbi
310
# db_scheme2dbi
297
# Translates the full text name of a database into de appropiate dbi name
311
# Translates the full text name of a database into de appropiate dbi name
298
# 
312
# 
(-)a/C4/Languages.pm (-3 / +3 lines)
Lines 30-38 eval { Link Here
30
        require Memoize::Memcached;
30
        require Memoize::Memcached;
31
        import Memoize::Memcached qw(memoize_memcached);
31
        import Memoize::Memcached qw(memoize_memcached);
32
32
33
        memoize_memcached('getTranslatedLanguages', memcached => C4::Context->memcached);
33
        memoize_memcached('getTranslatedLanguages', memcached => C4::Context->memcached_params);
34
        memoize_memcached('getFrameworkLanguages' , memcached => C4::Context->memcached);
34
        memoize_memcached('getFrameworkLanguages' , memcached => C4::Context->memcached_params);
35
        memoize_memcached('getAllLanguages',        memcached => C4::Context->memcached);
35
        memoize_memcached('getAllLanguages',        memcached => C4::Context->memcached_params);
36
    }
36
    }
37
};
37
};
38
38
(-)a/C4/SQLHelper.pm (-11 / +3 lines)
Lines 28-46 require Exporter; Link Here
28
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
28
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
29
29
30
eval {
30
eval {
31
    my $servers = C4::Context->config('memcached_servers');
31
    if (C4::Context->ismemcached) {
32
    if ($servers) {
33
        require Memoize::Memcached;
32
        require Memoize::Memcached;
34
        import Memoize::Memcached qw(memoize_memcached);
33
        import Memoize::Memcached qw(memoize_memcached);
35
34
36
        my $memcached = {
35
        memoize_memcached( '_get_columns',   memcached => C4::Context->memcached_params() );
37
            servers     => [$servers],
36
        memoize_memcached( 'GetPrimaryKeys', memcached => C4::Context->memcached_params() );
38
            key_prefix  => C4::Context->config('memcached_namespace') || 'koha',
39
            expire_time => 600
40
        };    # cache for 10 mins
41
42
        memoize_memcached( '_get_columns',   memcached => $memcached );
43
        memoize_memcached( 'GetPrimaryKeys', memcached => $memcached );
44
    }
37
    }
45
};
38
};
46
39
47
- 

Return to bug 10503