]> projects.mako.cc - selectricity/commitdiff
turned off memcache as it was causing trouble
author<mako@atdot.cc> <>
Wed, 5 Sep 2007 19:20:05 +0000 (15:20 -0400)
committer<mako@atdot.cc> <>
Wed, 5 Sep 2007 19:20:05 +0000 (15:20 -0400)
app/controllers/quickvote_controller.rb
app/models/election.rb
app/views/quickvote/list_voters.rhtml
config/environments/production.rb

index 5bf259caf7427d89a9149437ee52844bac93a295..eef3402c109ac813237ce739748345c9d30b02f8 100644 (file)
@@ -169,8 +169,8 @@ class QuickvoteController < ApplicationController
     @election.voters.each do |voter|
       next unless voter.ipaddress
       location=nil
     @election.voters.each do |voter|
       next unless voter.ipaddress
       location=nil
-      if Cache and location=Cache.get("GEO:#{voter.ipaddress}")
-      elsif Cache
+      if defined? Cache and location=Cache.get("GEO:#{voter.ipaddress}")
+      elsif defined? Cache
         location = GeoKit::Geocoders::IpGeocoder.geocode(voter.ipaddress)
         Cache.set "GEO:#{voter.ipaddress}", location
       else
         location = GeoKit::Geocoders::IpGeocoder.geocode(voter.ipaddress)
         Cache.set "GEO:#{voter.ipaddress}", location
       else
index 99d64f93cc55424b34f82dac24d0dce9a1e4fc73..cd809ab5b94e28a06c6ed4cdbaaaacaf4cc90148 100644 (file)
@@ -91,14 +91,14 @@ class Election < ActiveRecord::Base
   #Calculate results if not in memcache
   def results
     # Assignment is intentional
   #Calculate results if not in memcache
   def results
     # Assignment is intentional
-    if Cache and c = Cache.get("election_results:#{id}:#{self.votes.length}")
+    if defined? Cache and c = Cache.get("election_results:#{id}:#{self.votes.length}")
       @plurality_result = c['plurality']
       @approval_result = c['approval']
       @condorcet_result = c['condorcet']
       @ssd_result = c['ssd']
       @borda_result = c['borda']
       return c
       @plurality_result = c['plurality']
       @approval_result = c['approval']
       @condorcet_result = c['condorcet']
       @ssd_result = c['ssd']
       @borda_result = c['borda']
       return c
-    elsif Cache
+    elsif defined? Cache
       # memcache is available, but missed.
       results = self.results!
       Cache.set("election_results:#{id}:#{self.votes.length}", results)
       # memcache is available, but missed.
       results = self.results!
       Cache.set("election_results:#{id}:#{self.votes.length}", results)
index cdfc049ae28808cbd5331e63d3f0383b2ba3fdcd..b0dc6dd96768b6662768d25bb3fad0bc17e29654 100644 (file)
@@ -27,8 +27,8 @@
             voter.ipaddress =~ /^172\.[1-3]/
             %>
             <% w=nil
             voter.ipaddress =~ /^172\.[1-3]/
             %>
             <% w=nil
-            if Cache and w=Cache.get("WHOIS:#{voter.ipaddress}")
-            elsif Cache
+            if defined? Cache and w=Cache.get("WHOIS:#{voter.ipaddress}")
+            elsif defined? Cache
               w= Whois::Whois.new(IPAddr.new(voter.ipaddress),true)
               w.search_whois
               Cache.set("WHOIS:#{voter.ipaddress}", w)
               w= Whois::Whois.new(IPAddr.new(voter.ipaddress),true)
               w.search_whois
               Cache.set("WHOIS:#{voter.ipaddress}", w)
index 3192ef53fe394680cdc5785a3605c9ccfc1656ca..d1b8f88479fbf2597c18ed3baaae3c5a2f248909 100644 (file)
@@ -1,8 +1,8 @@
 # Settings specified here will take precedence over those in config/environment.rb
 #
 #Enable memcache
 # Settings specified here will take precedence over those in config/environment.rb
 #
 #Enable memcache
-require('memcache')
-Cache=MemCache.new('localhost', :compression => true)
+#require('memcache')
+#Cache=MemCache.new('localhost', :compression => true)
 # The production environment is meant for finished, "live" apps.
 # Code is not reloaded between requests
 config.cache_classes = true
 # The production environment is meant for finished, "live" apps.
 # Code is not reloaded between requests
 config.cache_classes = true

Benjamin Mako Hill || Want to submit a patch?