Skip to content

Commit 2844307

Browse files
author
Hanna Seweryn
committedMay 9, 2011
fix logger using braces instead of parenthesis
1 parent e14dd22 commit 2844307

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed
 

‎lib/dalli/client.rb

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# encoding: ascii
22
module Dalli
33
class Client
4-
4+
55
##
66
# Dalli::Client is the main class which developers will use to interact with
77
# the memcached server. Usage:
8-
#
9-
# Dalli::Client.new(['localhost:11211:10', 'cache-2.example.com:11211:5', '192.168.0.1:22122:5'],
8+
#
9+
# Dalli::Client.new(['localhost:11211:10', 'cache-2.example.com:11211:5', '192.168.0.1:22122:5'],
1010
# :threadsafe => true, :failover => true, :expires_in => 300)
11-
#
11+
#
1212
# servers is an Array of "host:port:weight" where weight allows you to distribute cache unevenly.
1313
# Both weight and port are optional. If you pass in nil, Dalli will default to 'localhost:11211'.
1414
# Note that the <tt>MEMCACHE_SERVERS</tt> environment variable will override the servers parameter for use
@@ -39,7 +39,7 @@ def self.compatibility_mode=(compatibility_mode)
3939
require 'dalli/compatibility'
4040
@compatibility_mode = compatibility_mode
4141
end
42-
42+
4343
#
4444
# The standard memcached instruction set
4545
#
@@ -81,8 +81,8 @@ def get_multi(*keys)
8181
values[key_without_namespace(key)] = value
8282
end
8383
rescue NetworkError => e
84-
Dalli.logger.debug { e.message }
85-
Dalli.logger.debug { "results from this server will be missing" }
84+
Dalli.logger.debug(e.message)
85+
Dalli.logger.debug("results from this server will be missing")
8686
end
8787
end
8888
values
@@ -165,7 +165,7 @@ def flush(delay=0)
165165
##
166166
# Incr adds the given amount to the counter on the memcached server.
167167
# Amt must be a positive value.
168-
#
168+
#
169169
# memcached counters are unsigned and cannot hold negative values. Calling
170170
# decr on a counter which is 0 will just return 0.
171171
#
@@ -181,7 +181,7 @@ def incr(key, amt=1, ttl=nil, default=nil)
181181
##
182182
# Decr subtracts the given amount from the counter on the memcached server.
183183
# Amt must be a positive value.
184-
#
184+
#
185185
# memcached counters are unsigned and cannot hold negative values. Calling
186186
# decr on a counter which is 0 will just return 0.
187187
#
@@ -239,20 +239,20 @@ def perform(op, key, *args)
239239
server = ring.server_for_key(key)
240240
server.request(op, key, *args)
241241
rescue NetworkError => e
242-
Dalli.logger.debug { e.message }
243-
Dalli.logger.debug { "retrying request with new server" }
242+
Dalli.logger.debug(e.message)
243+
Dalli.logger.debug("retrying request with new server")
244244
retry
245245
end
246246
end
247-
247+
248248
def validate_key(key)
249249
raise ArgumentError, "illegal character in key #{key}" if key.respond_to?(:ascii_only?) && !key.ascii_only?
250250
raise ArgumentError, "illegal character in key #{key}" if key =~ /\s/
251251
raise ArgumentError, "illegal character in key #{key}" if key =~ /[\x00-\x20\x80-\xFF]/
252252
raise ArgumentError, "key cannot be blank" if key.nil? || key.strip.size == 0
253253
raise ArgumentError, "key too long #{key.inspect}" if key.length > 250
254254
end
255-
255+
256256
def key_with_namespace(key)
257257
@options[:namespace] ? "#{@options[:namespace]}:#{key}" : key
258258
end

‎lib/dalli/server.rb

+17-17
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Server
88
attr_accessor :port
99
attr_accessor :weight
1010
attr_accessor :options
11-
11+
1212
DEFAULTS = {
1313
# seconds between trying to contact a remote server
1414
:down_retry_delay => 1,
@@ -37,7 +37,7 @@ def initialize(attribs, options = {})
3737
@sock = nil
3838
@msg = nil
3939
end
40-
40+
4141
# Chokepoint method for instrumentation
4242
def request(op, *args)
4343
raise Dalli::NetworkError, "#{hostname}:#{port} is down: #{@error} #{@msg}" unless alive?
@@ -65,7 +65,7 @@ def alive?
6565

6666
if @last_down_at && @last_down_at + options[:down_retry_delay] >= Time.now
6767
time = @last_down_at + options[:down_retry_delay] - Time.now
68-
Dalli.logger.debug { "down_retry_delay not reached for #{hostname}:#{port} (%.3f seconds left)" % time }
68+
Dalli.logger.debug("down_retry_delay not reached for #{hostname}:#{port} (%.3f seconds left)" % time )
6969
return false
7070
end
7171

@@ -92,7 +92,7 @@ def unlock!
9292
private
9393

9494
def failure!
95-
Dalli.logger.info { "#{hostname}:#{port} failed (count: #{@fail_count})" }
95+
Dalli.logger.info("#{hostname}:#{port} failed (count: #{@fail_count})")
9696

9797
@fail_count += 1
9898
if @fail_count >= options[:socket_max_failures]
@@ -101,18 +101,18 @@ def failure!
101101
sleep(options[:socket_failure_delay]) if options[:socket_failure_delay]
102102
end
103103
end
104-
104+
105105
def down!
106106
close
107107

108108
@last_down_at = Time.now
109109

110110
if @down_at
111111
time = Time.now - @down_at
112-
Dalli.logger.debug { "#{hostname}:#{port} is still down (for %.3f seconds now)" % time }
112+
Dalli.logger.debug("#{hostname}:#{port} is still down (for %.3f seconds now)" % time)
113113
else
114114
@down_at = @last_down_at
115-
Dalli.logger.warn { "#{hostname}:#{port} is down" }
115+
Dalli.logger.warn("#{hostname}:#{port} is down")
116116
end
117117

118118
@error = $! && $!.class.name
@@ -123,7 +123,7 @@ def down!
123123
def up!
124124
if @down_at
125125
time = Time.now - @down_at
126-
Dalli.logger.warn { "#{hostname}:#{port} is back (downtime was %.3f seconds)" % time }
126+
Dalli.logger.warn("#{hostname}:#{port} is back (downtime was %.3f seconds)" % time)
127127
end
128128

129129
@fail_count = 0
@@ -163,7 +163,7 @@ def add(key, value, ttl, cas, options)
163163
write(req)
164164
generic_response unless multi?
165165
end
166-
166+
167167
def replace(key, value, ttl, options)
168168
(value, flags) = serialize(key, value, options)
169169
req = [REQUEST, OPCODES[multi? ? :replaceq : :replace], key.bytesize, 8, 0, 0, value.bytesize + key.bytesize + 8, 0, 0, flags, ttl, key, value].pack(FORMAT[:replace])
@@ -193,7 +193,7 @@ def decr(key, count, ttl, default)
193193
body = generic_response
194194
body ? longlong(*body.unpack('NN')) : body
195195
end
196-
196+
197197
def incr(key, count, ttl, default)
198198
expiry = default ? ttl : 0xFFFFFFFF
199199
default ||= 0
@@ -204,7 +204,7 @@ def incr(key, count, ttl, default)
204204
body = generic_response
205205
body ? longlong(*body.unpack('NN')) : body
206206
end
207-
207+
208208
# Noop is a keepalive operation but also used to demarcate the end of a set of pipelined commands.
209209
# We need to read all the responses at once.
210210
def noop
@@ -376,7 +376,7 @@ def read(count)
376376
end
377377

378378
def connect
379-
Dalli.logger.debug { "Dalli::Server#connect #{hostname}:#{port}" }
379+
Dalli.logger.debug("Dalli::Server#connect #{hostname}:#{port}")
380380

381381
begin
382382
@sock = KSocket.open(hostname, port, :timeout => options[:socket_timeout])
@@ -401,7 +401,7 @@ def longlong(a, b)
401401

402402
REQUEST = 0x80
403403
RESPONSE = 0x81
404-
404+
405405
RESPONSE_CODES = {
406406
0 => 'No error',
407407
1 => 'Key not found',
@@ -414,7 +414,7 @@ def longlong(a, b)
414414
0x81 => 'Unknown command',
415415
0x82 => 'Out of memory',
416416
}
417-
417+
418418
OPCODES = {
419419
:get => 0x00,
420420
:set => 0x01,
@@ -440,7 +440,7 @@ def longlong(a, b)
440440
:auth_request => 0x21,
441441
:auth_continue => 0x22,
442442
}
443-
443+
444444
HEADER = "CCnCCnNNQ"
445445
OP_FORMAT = {
446446
:get => 'a*',
@@ -470,7 +470,7 @@ def longlong(a, b)
470470
def need_auth?
471471
@options[:username] || ENV['MEMCACHE_USERNAME']
472472
end
473-
473+
474474
def username
475475
@options[:username] || ENV['MEMCACHE_USERNAME']
476476
end
@@ -480,7 +480,7 @@ def password
480480
end
481481

482482
def sasl_authentication
483-
Dalli.logger.info { "Dalli/SASL authenticating as #{username}" }
483+
Dalli.logger.info("Dalli/SASL authenticating as #{username}")
484484

485485
# negotiate
486486
req = [REQUEST, OPCODES[:auth_negotiation], 0, 0, 0, 0, 0, 0, 0].pack(FORMAT[:noop])

0 commit comments

Comments
 (0)
Please sign in to comment.