Module: Seymour
- Extended by:
- Seymour
- Included in:
- Seymour
- Defined in:
- lib/seymour.rb,
lib/seymour/feed.rb,
lib/seymour/redis.rb,
lib/seymour/store.rb,
lib/seymour/engine.rb,
lib/seymour/railtie.rb,
lib/seymour/version.rb,
lib/seymour/renderable.rb,
lib/seymour/store/base.rb,
lib/seymour/store/list.rb,
lib/seymour/store/zset.rb,
lib/seymour/distributable.rb,
lib/seymour/acts_as_activity.rb,
lib/seymour/render_controller.rb,
lib/generators/seymour/feed/feed_generator.rb
Defined Under Namespace
Modules: ActsAsActivity, Distributable, Redis, Renderable, Store Classes: Engine, Feed, FeedGenerator, Railtie, RenderController, RenderError
Constant Summary collapse
- VERSION =
"0.0.9"
Instance Method Summary collapse
-
#redis ⇒ Object
Courtesy of resque Returns the current Redis connection.
-
#redis=(server) ⇒ Object
Accepts: 1.
Instance Method Details
#redis ⇒ Object
Courtesy of resque Returns the current Redis connection. If none has been created, will create a new one.
12 13 14 15 16 |
# File 'lib/seymour/redis.rb', line 12 def redis return @redis if @redis self.redis = ::Redis.respond_to?(:connect) ? ::Redis.connect : "localhost:6379" self.redis end |
#redis=(server) ⇒ Object
Accepts:
1. A 'hostname:port' String
2. A 'hostname:port:db' String (to select the Redis db)
3. A 'hostname:port/namespace' String (to set the Redis namespace)
4. A Redis URL String 'redis://host:port'
5. An instance of `Redis`, `Redis::Client`, `Redis::DistRedis`,
or `Redis::Namespace`.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/seymour/redis.rb', line 25 def redis=(server) case server when String if server =~ /redis\:\/\// redis = ::Redis.connect(:url => server, :thread_safe => true) else server, namespace = server.split('/', 2) host, port, db = server.split(':') redis = ::Redis.new(:host => host, :port => port, :thread_safe => true, :db => db) end namespace ||= :seymour @redis = ::Redis::Namespace.new(namespace, :redis => redis) when ::Redis::Namespace @redis = server else @redis = ::Redis::Namespace.new(:seymour, :redis => server) end end |