syncache 1.3 → 1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad9a99425eda744305f5d8040e296132bff7e063
4
- data.tar.gz: 5b9352dd51839233cf65b4463d00b378b6a76cf1
3
+ metadata.gz: c487d4bfefbcf5d5e454a7e2f8327ddac723078b
4
+ data.tar.gz: 143b0b8757fe2e0c37b18d3d74e10c9287b2c360
5
5
  SHA512:
6
- metadata.gz: 9fae2c8ec3d435e712430fb251df22472dea9dff97ca8632d0335e416da449665357d4b799d5868c61b34b13376cb95c65e9798851e76ffc097ec3068c5afa01
7
- data.tar.gz: 333db769142c045ee37527ca36384e491446e39410d82ce3f19a858d144eb4573ab1847c3d6d99723bb478986c5a4bc3543b21406f27dd3ac6fea97d967bff43
6
+ metadata.gz: 49a98a66e098c88d99b4eac27c226d258ba93576ec7d24c6aa4d2f8f59cb8a149606ac455c6c6e747fd07dd789a7ba0c47c55fd473a1342c1d9370148ce89239
7
+ data.tar.gz: fa146f3504e6c3b782fbbe6a347a02242a549f3e3bb1098ed8540df20cc23aa87192977815195261d3f17d65c34c1f335808b83b1e3ce170bbb6d5f51466a078
@@ -0,0 +1,18 @@
1
+ # SynCache dRuby object cache server
2
+ # (originally written for Samizdat project)
3
+ #
4
+ # Copyright (c) 2002-2012, 2016 Dmitry Borodaenko <angdraug@debian.org>
5
+ #
6
+ # This program is free software.
7
+ # You can distribute/modify this program under the terms of
8
+ # the GNU General Public License version 3 or later.
9
+ #
10
+ # vim: et sw=2 sts=2 ts=8 tw=0
11
+
12
+ require "rake"
13
+
14
+ task :default => :test
15
+
16
+ task :test do
17
+ sh %{#{FileUtils::RUBY} -I. -Ilib test/ts_syncache.rb}
18
+ end
@@ -28,7 +28,7 @@ Options:
28
28
 
29
29
  URI
30
30
  URI with druby: schema that DRb server binds to, default is
31
- druby://localhost:9000
31
+ druby://*:9000
32
32
 
33
33
  --help
34
34
  display this message and quit
@@ -60,6 +60,10 @@ Options:
60
60
  /var/run/#{PNAME}/ when run as root, or under $TMPDIR
61
61
  otherwise. Location should be writeable by USER.
62
62
 
63
+ --foreground
64
+ Do not daemonize, switch to a different user, create pidfile,
65
+ redirect output, or log to syslog.
66
+
63
67
  }
64
68
  exit
65
69
  end
@@ -73,10 +77,11 @@ Options:
73
77
  [ '--user', '-u', GetoptLong::REQUIRED_ARGUMENT ],
74
78
  [ '--error-log', '-e', GetoptLong::REQUIRED_ARGUMENT ],
75
79
  [ '--debug', '-d', GetoptLong::NO_ARGUMENT ],
76
- [ '--pidfile', '-p', GetoptLong::REQUIRED_ARGUMENT ]
80
+ [ '--pidfile', '-p', GetoptLong::REQUIRED_ARGUMENT ],
81
+ [ '--foreground', GetoptLong::NO_ARGUMENT ]
77
82
  )
78
83
 
79
- @uri = 'druby://localhost:9000'
84
+ @uri = 'druby://*:9000'
80
85
  @ttl = 24*60*60
81
86
  @size = 10000
82
87
  @flush_delay = nil
@@ -85,7 +90,9 @@ Options:
85
90
  @debug = false
86
91
  @pidfile = (0 == Process.uid) ?
87
92
  "/var/run/#{PNAME}/#{PNAME}.pid" :
88
- (ENV.has_key?('TMPDIR') ? ENV['TMPDIR'] : '/tmp') + "/#{PNAME}.pid"
93
+ File.join((ENV.has_key?('TMPDIR') ? ENV['TMPDIR'].dup.untaint : '/tmp'),
94
+ "#{PNAME}.pid")
95
+ @foreground = false
89
96
 
90
97
  opts.each do |opt, arg|
91
98
  case opt
@@ -105,6 +112,8 @@ Options:
105
112
  @debug = true
106
113
  when '--pidfile'
107
114
  @pidfile = arg.dup.untaint
115
+ when '--foreground'
116
+ @foreground = true
108
117
  end
109
118
  end
110
119
 
@@ -183,14 +192,16 @@ Options:
183
192
 
184
193
  def wait_for_shutdown
185
194
  DRb.thread.join
186
- File.delete @pidfile
195
+ File.delete @pidfile unless @foreground
187
196
  log 'shut down'
188
197
  end
189
198
 
190
199
  def run
191
200
  set_options
192
- daemonize
193
- open_syslog unless @debug and @error_log
201
+ unless @foreground
202
+ daemonize
203
+ open_syslog unless @debug and @error_log
204
+ end
194
205
  begin
195
206
  ready
196
207
  trap_signals
@@ -74,9 +74,9 @@ class RemoteCache
74
74
  value = @cache[key]
75
75
  end
76
76
 
77
- if value.kind_of?(Placeholder)
78
- # ran out of time: give up and do it ourselves
79
- @cache.delete(key)
77
+ if value.kind_of?(Placeholder) or value.nil?
78
+ # the other client timed out or got flushed;
79
+ # reset the placeholder ttl and do it ourselves
80
80
  @cache[key] = Placeholder.new
81
81
  value = @cache[key] = yield
82
82
  end
@@ -14,7 +14,7 @@ replacement strategy.
14
14
  .SH "OPTIONS"
15
15
  .IP "\fBURI\fP" 4
16
16
  A URI with druby: schema that the DRb server binds to, default is
17
- \fBdruby://localhost:9000\fP
17
+ \fBdruby://*:9000\fP
18
18
  .IP "\fB--help\fP" 4
19
19
  Display usage information and quit.
20
20
  .IP "\fB--ttl\fP SECONDS" 4
@@ -36,6 +36,9 @@ messages will be sent there instead of syslog.
36
36
  Path to pidfile. By default, pidfile is created under /var/run/syncache-drb/
37
37
  when run as root, or under $TMPDIR otherwise. Location should be writeable by
38
38
  USER.
39
+ .IP "\fB--foreground\fP" 4
40
+ Do not daemonize, switch to a different user, create pidfile, redirect output,
41
+ or log to syslog.
39
42
 
40
43
  .SH "AUTHOR"
41
44
  .PP
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'syncache'
3
- spec.version = '1.3'
3
+ spec.version = '1.4'
4
4
  spec.author = 'Dmitry Borodaenko'
5
5
  spec.email = 'angdraug@debian.org'
6
6
  spec.homepage = 'https://github.com/angdraug/syncache'
@@ -18,8 +18,10 @@ two-level locking mechanism which ensures that:
18
18
  and as soon as the first thread completes the operation, the result will be
19
19
  returned to all threads.
20
20
  EOF
21
- spec.files = `git ls-files`.split "\n"
21
+ spec.files = %w(COPYING ChangeLog.mtn README.rdoc setup.rb Rakefile
22
+ syncache.gemspec bin/syncache-drb man/syncache-drb.1) +
23
+ Dir['{lib,test}/**/*.rb']
22
24
  spec.test_files = Dir['test/ts_*.rb']
23
25
  spec.executables = spec.files.map{|p| p =~ /^bin\/(.*)/ ? $1 : nil }.compact
24
- spec.license = 'GPL3+'
26
+ spec.license = 'GPL-3.0+'
25
27
  end
@@ -10,6 +10,5 @@
10
10
  #
11
11
  # vim: et sw=2 sts=2 ts=8 tw=0
12
12
 
13
- require 'test/unit'
14
13
  require 'test/tc_syncache'
15
14
  require 'test/tc_remote'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syncache
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
4
+ version: '1.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Borodaenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-15 00:00:00.000000000 Z
11
+ date: 2016-04-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  SynCache stores cached objects in a Hash that is protected by an advanced
@@ -31,6 +31,7 @@ files:
31
31
  - COPYING
32
32
  - ChangeLog.mtn
33
33
  - README.rdoc
34
+ - Rakefile
34
35
  - bin/syncache-drb
35
36
  - lib/syncache.rb
36
37
  - lib/syncache/remote.rb
@@ -43,7 +44,7 @@ files:
43
44
  - test/ts_syncache.rb
44
45
  homepage: https://github.com/angdraug/syncache
45
46
  licenses:
46
- - GPL3+
47
+ - GPL-3.0+
47
48
  metadata: {}
48
49
  post_install_message:
49
50
  rdoc_options: []
@@ -61,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
62
  version: '0'
62
63
  requirements: []
63
64
  rubyforge_project:
64
- rubygems_version: 2.4.5.1
65
+ rubygems_version: 2.5.1
65
66
  signing_key:
66
67
  specification_version: 4
67
68
  summary: Thread-safe time-limited cache with flexible replacement policy