Commits

Andriy Kornatskyy committed 5260138

Refactored caching benchmark to use latest wheezy.web version.

  • Participants
  • Parent commits ae9b798

Comments (0)

Files changed (3)

File 07-caching/Makefile

 		cd $(ENV)/bin && ./easy_install-$(VERSION) -i $(PYPI) -O2 \
 			"uwsgi>=1.2.6" "gunicorn>=0.14.6" \
 			"python-memcached>=1.48" "pylibmc>=1.2.3" \
-			"django>=1.4.2" "wheezy.web>=0.1.307" "Flask-Cache>=0.9.0"; \
+			"django>=1.4.2" "wheezy.web>=0.1.315" "Flask-Cache>=0.9.0"; \
 	else \
 		cd $(ENV)/bin && ./easy_install-$(VERSION) -i $(PYPI) \
 				"distribute>=0.6.28" \
 			&& ./easy_install-$(VERSION) -i $(PYPI) -O2 \
 		   		"uwsgi>=1.3" "python-memcached>=1.48" \
-		   		"wheezy.web>=0.1.307" ; \
+		   		"wheezy.web>=0.1.315" ; \
 	fi
 
 pypy:
 	$(PYPY)/bin/pypy distribute_setup.py ; \
 	rm distribute* ; \
 	cd $(PYPY)/bin && ./easy_install -i $(PYPI) -O2 \
-		"gunicorn>=0.14.6" "python-memcached>=1.48" "wheezy.web>=0.1.307" \
+		"gunicorn>=0.14.6" "python-memcached>=1.48" "wheezy.web>=0.1.315" \
 		"Flask-Cache>=0.9.0"
 
 clean:

File 07-caching/wheezy.web/app.py

 from wheezy.web.middleware import bootstrap_defaults
 from wheezy.web.middleware import path_routing_middleware_factory
 
-from config import cache_factory
+from config import cache
 from urls import all_urls
 
 
 
 # HTTPCacheMiddleware
 options.update({
-    'http_cache_factory': cache_factory
+    'http_cache': cache
 })
 
 warnings.simplefilter('ignore')

File 07-caching/wheezy.web/config.py

 
 from datetime import timedelta
 
+from wheezy.core.pooling import EagerPool
 from wheezy.caching import CacheClient
 from wheezy.caching import MemoryCache
-from wheezy.caching.memcache import client_factory as memcache_factory
-from wheezy.caching.pools import EagerPool
-from wheezy.caching.pools import Pooled
+from wheezy.caching.memcache import MemcachedClient
 from wheezy.caching.pylibmc import client_factory as pylibmc_factory
+from wheezy.caching.pylibmc import MemcachedClient as PylibmcClient
 from wheezy.http import CacheProfile
 
 
 
 memory_cache = MemoryCache()
 
-memcache_cache = memcache_factory(['unix:/tmp/memcached.sock'],
-        key_encode=lambda key: key.replace(' ', '_'))
+memcache_cache = MemcachedClient(['unix:/tmp/memcached.sock'],
+                                 key_encode=lambda key: key.replace(' ', '_'))
 
 pylibmc_pool = EagerPool(lambda: pylibmc_factory(['/tmp/memcached.sock']),
                          size=100)
 
 cache = CacheClient({
-    'memory': lambda: memory_cache,
-    'memcache': lambda: memcache_cache,
-    'pylibmc': lambda: Pooled(pylibmc_pool)
+    'memory': memory_cache,
+    'memcache': memcache_cache,
+    'pylibmc':  PylibmcClient(pylibmc_pool)
 }, default_namespace='memory')
 
-cache_factory = lambda: cache
-
 # cache profiles
 
 memory_profile = CacheProfile(