Permalink
Browse files

added partial object cache and bind to all interfaces

  • Loading branch information...
1 parent 1877d03 commit 4c9631a8610e813148b5c0d74033cef45362be50 @schacon committed Aug 10, 2009
Showing with 6 additions and 2 deletions.
  1. +1 −1 bin/agit-daemon
  2. +5 −1 dulwich/agitmemnon.py
View
@@ -6,5 +6,5 @@ from dulwich.agitmemnon import *
if __name__ == "__main__":
backend = AgitmemnonBackend()
- server = TCPGitServer(backend, 'localhost')
+ server = TCPGitServer(backend, '0.0.0.0')
server.serve_forever()
View
@@ -34,6 +34,7 @@ def __init__(self):
host = '127.0.0.1'
port = 9160
self.keyspace = 'Agitmemnon'
+ self.memcache = {}
socket = TSocket.TSocket(host, port)
transport = TTransport.TBufferedTransport(socket)
@@ -73,7 +74,6 @@ def get_object(self, sha):
def get_object_value(self, sha, column):
return self.get_value('Objects', sha, column)
- # TODO: modify to only check cassandra for the key (maybe just look for the size)
def __contains__(self, sha):
"""Check if the object with a particular SHA is present."""
if self.get_object_value(sha, 'size'):
@@ -83,6 +83,8 @@ def __contains__(self, sha):
# TODO: look for packfiles of objects, cache all items in packfile, pull from caches
def __getitem__(self, name):
+ if name in self.memcache:
+ return self.memcache[name]
o = self.get_object(name)
data = ''
otype = ''
@@ -93,6 +95,8 @@ def __getitem__(self, name):
otype = col.value
data = zlib.decompress(base64.b64decode(data))
shafile = ShaFile.from_raw_string(type_num_map[otype], data)
+ if otype != BLOB_ID: # caching commit/tree/tag objects since they are hit twice
+ self.memcache[name] = shafile
return shafile

0 comments on commit 4c9631a

Please sign in to comment.