Merge lp:~stub/launchpad/memcache into lp:launchpad

Proposed by Stuart Bishop on 2010-03-17
Status: Merged
Approved by: Tim Penhey on 2010-03-17
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~stub/launchpad/memcache
Merge into: lp:launchpad
Diff against target: 24 lines (+5/-2)
1 file modified
lib/lp/services/memcache/tales.py (+5/-2)
To merge this branch: bzr merge lp:~stub/launchpad/memcache
Reviewer Review Type Date Requested Status
Tim Penhey (community) 2010-03-17 Approve on 2010-03-17
Review via email: mp+21534@code.launchpad.net

Description of the Change

The TALES memcache integration is showing significant performance gains... when the cache is hit. Unfortunately, individual appservers are not sharing cache because they each use an individual config file. We use the config name as part of the cache key because we don't want lpnet and edge servers sharing cached information, but do want them using the same memcached servers. Stripping the digits from the end of the config name is a quick and simple way of doing what we need - allowing edge1-4 to share cache with each other but not with lpnet1-16.

To post a comment you must log in.
Tim Penhey (thumper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/services/memcache/tales.py'
2--- lib/lp/services/memcache/tales.py 2010-03-03 10:31:33 +0000
3+++ lib/lp/services/memcache/tales.py 2010-03-17 07:45:43 +0000
4@@ -109,6 +109,10 @@
5 '_'*33 + ''.join(chr(i) for i in range(33, ord(':'))) + '_'
6 + ''.join(chr(i) for i in range(ord(':')+1, 127)) + '_' * 129)
7
8+ # We strip digits from our LPCONFIG when generating the key
9+ # to ensure that edge1 and edge4 share cache.
10+ _lpconfig = config.instance_name.rstrip('0123456789')
11+
12 def getKey(self, econtext):
13 """We need to calculate a unique key for this cached chunk.
14
15@@ -165,8 +169,7 @@
16 # tools - it doesn't really matter provided all the components are
17 # included and separators used.
18 key = "pt:%s:%s,%s:%s:%d,%d:%d,%s" % (
19- config.instance_name,
20- source_file, versioninfo.revno, uid,
21+ self._lpconfig, source_file, versioninfo.revno, uid,
22 econtext.position[0], econtext.position[1], counter,
23 sanitized_url,
24 )