Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove null check in memcache wrapper - just pass through. Ignore int…

…egrity check on inserts into mysql
  • Loading branch information...
commit f3e194b276336b195a0e2594a1b41a328d0721ef 1 parent 59645d8
@harryf authored
Showing with 14 additions and 8 deletions.
  1. +4 −2 dammit/db_cache.py
  2. +9 −2 dammit/db_mysql.py
  3. +1 −4 dammit/mcwrapper.py
View
6 dammit/db_cache.py
@@ -9,9 +9,11 @@ def load(method):
Decorator for load method
"""
def load_wrapper(self, id):
- if not id in cache:
+ try:
+ return cache[id]
+ except:
cache[id] = method(self, id)
- return cache[id]
+ return cache[id]
return load_wrapper
View
11 dammit/db_mysql.py
@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import time
import MySQLdb
+from MySQLdb import IntegrityError
from uri import URI
import db_cache, constants
@@ -80,7 +81,8 @@ def load(self, id):
cursor.execute(sql, (id, ))
row = cursor.fetchone()
- if not row: return None
+ if not row:
+ return None
data = {}
data['uri'] = None
@@ -133,7 +135,12 @@ def insert(self, uri):
todatetime(uri.created),
todatetime(uri.updated)
)
- cursor.execute( sql, params )
+
+ try:
+ cursor.execute( sql, params )
+ except IntegrityError:
+ # Duplicate key - we don't care
+ return
self._store_tags(cursor, uri, deletefirst = False)
self._store_pairs(cursor, uri, deletefirst = False)
View
5 dammit/mcwrapper.py
@@ -40,10 +40,7 @@ def __setitem__(self, key, val):
@namespacer
def __getitem__(self, key):
- val = self.mc.get(key)
- if val == None:
- raise KeyError(key)
- return val
+ return self.mc.get(key)
@namespacer
def __delitem__(self, key):
Please sign in to comment.
Something went wrong with that request. Please try again.