Skip to content

Commit

Permalink
language changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Cantino committed Apr 10, 2012
1 parent 34cdeab commit cf17523
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
6 changes: 4 additions & 2 deletions README.markdown
Expand Up @@ -28,7 +28,7 @@ With Bundler:

gem 'morlock', :require => 'morlock/rails'

Or in any script after Rails has loaded:
Or in any script:

require 'morlock/rails'

Expand All @@ -41,11 +41,13 @@ Possible usages:
handle_failed_lock unless morlock.lock(key) do
# We have the lock
end

morlock.lock(key) { # We have the lock } || raise "Unable to lock!"

morlock.lock(key, :failure => failure_proc) do
# We have the lock
end

morlock.lock(key, :failure => failure_proc, :success => success_proc)

Morlock doesn't currently do retries, but this could be added in the future. Feel free to submit a patch!
10 changes: 5 additions & 5 deletions lib/morlock/gem_client.rb
@@ -1,6 +1,6 @@
class Morlock
class UnknownGemClient < StandardError;
end
class UnknownGemClient < StandardError; end


class GemClient
GEM_CLIENTS = []
Expand All @@ -18,16 +18,16 @@ def self.wrap(client)
end
end

raise UnknownGemClient.new("You provided Morlock a memcached client of an unknown type: #{client.class}")
raise UnknownGemClient.new("You provided Morlock with a memcached client of an unknown type: #{client.class}")
end


def no_server_error(e)
STDERR.puts "WARNING: No memcached server found; Memlock was unable to create a lock. (#{e.message})"
STDERR.puts "WARNING: No memcached server was found; Memlock was unable to create a lock. (#{e.message})"
true
end
end


class DalliGemClient < GemClient
def add(key, expiration)
@client.add(key, 1, expiration)
Expand Down
3 changes: 2 additions & 1 deletion lib/morlock/rails.rb
Expand Up @@ -12,6 +12,8 @@ def morlock
end
end
end
else
Rails.logger.warn "WARNING: Morlock could not load @data in #setup_for_mem_cache_store. Perhaps we don't yet work with this version of Rails?"
end
end

Expand Down Expand Up @@ -39,7 +41,6 @@ def self.detect_memcache_gem
else
Rails.logger.warn "WARNING: Morlock detected that you are not using the Rails ActiveSupport::Cache::MemCacheStore. Rails.morlock will not be setup."
end

end

config.after_initialize do
Expand Down
2 changes: 1 addition & 1 deletion lib/morlock/version.rb
@@ -1,3 +1,3 @@
class Morlock
VERSION = "0.0.4"
VERSION = "0.0.5"
end

0 comments on commit cf17523

Please sign in to comment.