Esempio n. 1
0
def delete_pattern_wrapper(pattern):
    start = time()
    try:
        return delete_pattern(pattern)
    except:
        if settings.DEBUG:
            raise
        else:
            return None
    finally:
        value = 'delete_pattern_wrapper'
        stop = time()
        duration = stop - start
        query = 'delete_pattern from `cache`: `%s`' % pattern
        if zipkin_client.zipkinClient:
            zipkin_client.zipkinClient.sendMessge(
                zipkin_client.TYPE_CALL_REDIS,
                duration,
                method='',
                resource=query,
                data='')

        CACHE_QUERIES.append({
            'source': 'redis',
            'query': query,
            'time': "%.3f" % duration,
            'stack': get_trace_back()
        })
Esempio n. 2
0
def get_many_wrapper(keys):
	start = time()
	success = False
	try:
		value = get_many(keys)
		if value:
			success = True
		return value
	except:
		if settings.DEBUG:
			raise
		else:
			return None
	finally:
		stop = time()
		duration = stop - start
		query = 'get_many from `cache`: `%s` => %s' % (keys, 'hit' if success else 'MISS!!')
		if zipkin_client.zipkinClient:
			zipkin_client.zipkinClient.sendMessge(zipkin_client.TYPE_CALL_REDIS, duration, method='', resource=query, data='')
		CACHE_QUERIES.append({
			'source': 'redis',
			'query': query,
			'time': "%.3f" % duration,
			'stack': get_trace_back()
		})
Esempio n. 3
0
def delete_cache_wrapper():
    start = time()
    try:
        return delete_cache()
    except:
        if settings.DEBUG:
            raise
        else:
            return None
    finally:
        value = 'delete_cache_wrapper'
        stop = time()
        duration = stop - start
        value_type = str(type(value)).replace('<', '&lt;').replace('>', '&gt;')
        query = 'delete `cache`: {`%s`: `%s`)' % (key, value_type)
        if zipkin_client.zipkinClient:
            zipkin_client.zipkinClient.sendMessge(
                zipkin_client.TYPE_CALL_REDIS,
                duration,
                method='',
                resource=query,
                data='')

        CACHE_QUERIES.append({
            'source': 'redis',
            'query': query,
            'time': "%.3f" % duration,
            'stack': get_trace_back()
        })