Skip to content
Newer
Older
100644 43 lines (34 sloc) 807 Bytes
b7545d3 Update pins/list as you drag the map, rearrange list display.
matthew authored
1 #
2 # Memcached.pm:
3 # Trying out memcached on FixMyStreet
4 #
5 # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
6 # Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
7 #
934ff73 Don't use connect()!
matthew authored
8 # $Id: Memcached.pm,v 1.3 2008-10-10 15:57:28 matthew Exp $
b7545d3 Update pins/list as you drag the map, rearrange list display.
matthew authored
9 #
10
11 package Memcached;
12
13 use strict;
14 use Cache::Memcached;
15
50e4a4f Different memcached namespace per site.
matthew authored
16 my ($memcache, $namespace);
17
18 sub set_namespace {
19 $namespace = shift;
20 $namespace = 'fms' if $namespace eq 'fixmystreet';
21 }
22
934ff73 Don't use connect()!
matthew authored
23 sub cache_connect {
50e4a4f Different memcached namespace per site.
matthew authored
24 $memcache = new Cache::Memcached {
25 'servers' => [ '127.0.0.1:11211' ],
26 'namespace' => $namespace,
27 'debug' => 0,
28 'compress_threshold' => 10_000,
29 };
30 }
b7545d3 Update pins/list as you drag the map, rearrange list display.
matthew authored
31
32 sub get {
934ff73 Don't use connect()!
matthew authored
33 cache_connect() unless $memcache;
b7545d3 Update pins/list as you drag the map, rearrange list display.
matthew authored
34 $memcache->get(@_);
35 }
36
37 sub set {
934ff73 Don't use connect()!
matthew authored
38 cache_connect() unless $memcache;
b7545d3 Update pins/list as you drag the map, rearrange list display.
matthew authored
39 $memcache->set(@_);
40 }
41
42 1;
Something went wrong with that request. Please try again.