Permalink
Browse files

common file uses global settings

  • Loading branch information...
1 parent d400da0 commit f9a943e1d4e067a6305809ce8fda6509b59a37dd Karl Seguin committed Oct 31, 2011
Showing with 9 additions and 10 deletions.
  1. 0 tmp/restart.txt
  2. +9 −10 tools/scraper/common.rb
View
No changes.
@@ -1,27 +1,26 @@
-require 'redis'
require 'json/ext'
+require File.dirname(__FILE__) + '/../../lib/store'
#require 'rubberband'
#require 'sanitize'
-
-$redis = Redis.new
-$redis.select(5)
-
#$es = ElasticSearch.new('127.0.0.1:9200', :index => "jobs", :type => "job")
module Store
def self.insert(job)
key = "#{job[:source]}:#{job[:source_id]}"
full_key = "job:#{key}"
serialized_job = job.to_json
- if $redis.exists(full_key)
- $redis.set(full_key, serialized_job)
+ if @@redis.exists(full_key)
+ @@redis.set(full_key, serialized_job)
else
- $redis.multi do
- $redis.set(full_key, serialized_job)
- $redis.zadd('jobs', job[:created_at].to_i, full_key)
+ @@redis.multi do
+ @@redis.set(full_key, serialized_job)
+ @@redis.zadd('jobs', job[:created_at].to_i, full_key)
end
end
#$es.index({:description => Sanitize.clean(job[:description]), :location => job[:location]}, :id => key)
end
end
+
+
+Store.setup

0 comments on commit f9a943e

Please sign in to comment.