tmp_cache 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.0.2 2012-05-05
2
+
3
+ * fix expiration
4
+
1
5
  === 0.0.1 2012-05-05
2
6
 
3
7
  * start
data/Manifest.txt CHANGED
@@ -3,7 +3,6 @@ Manifest.txt
3
3
  README.rdoc
4
4
  Rakefile
5
5
  lib/tmp_cache.rb
6
- lib/tmp_cache/cache.rb
7
6
  script/console
8
7
  script/destroy
9
8
  script/generate
data/README.rdoc CHANGED
@@ -11,13 +11,20 @@ on memory cache.
11
11
  #!/usr/bin/env ruby
12
12
  require 'tmp_cache'
13
13
 
14
- TmpCache.set('name', 'shokai', 2) # expire 2 sec
14
+ TmpCache.set('name', 'shokai', 60) # expire 60 sec
15
15
 
16
16
  puts TmpCache.get('name') # => 'shokai'
17
- sleep 3
17
+ sleep 61
18
18
  puts TmpCache.get('name') # => nil
19
19
 
20
20
 
21
+ TmpCache.set('name', 'shokai')
22
+ TmpCache.set('mail', 'hashimoto@shokai.org')
23
+ TmpCache.each do |k,v|
24
+ puts "#{k} => #{v}"
25
+ end
26
+
27
+
21
28
  == REQUIREMENTS:
22
29
 
23
30
  * Ruby 1.8.7+
data/lib/tmp_cache.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  module TmpCache
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
 
5
5
  def self.cache
6
6
  @@cache ||= Hash.new{|h,k| h = {:expire => 0, :value => nil}}
data/samples/sample.rb CHANGED
@@ -5,10 +5,10 @@ require 'rubygems'
5
5
 
6
6
  require 'tmp_cache'
7
7
 
8
- TmpCache.set('name', 'shokai', 2)
9
- puts TmpCache.get('name')
8
+ TmpCache.set('name', 'shokai', 2) # expire 2 sec
9
+ puts TmpCache.get('name') # => 'shokai'
10
10
  sleep 3
11
- puts TmpCache.get('name')
11
+ puts TmpCache.get('name') # => nil
12
12
 
13
13
 
14
14
  TmpCache.set('name', 'shokai')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tmp_cache
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sho Hashimoto
@@ -80,7 +80,6 @@ files:
80
80
  - README.rdoc
81
81
  - Rakefile
82
82
  - lib/tmp_cache.rb
83
- - lib/tmp_cache/cache.rb
84
83
  - script/console
85
84
  - script/destroy
86
85
  - script/generate
@@ -1,20 +0,0 @@
1
-
2
- module TmpCache
3
- class Cache
4
- def self.cache
5
- @@cache ||= Hash.new{|h,k| h = {:expire => 0, :value => nil}}
6
- end
7
-
8
- def self.set(key, value, expire=60)
9
- cache[key] = {:value => value, :expire => Time.now.to_i+expire}
10
- return value
11
- end
12
-
13
- def self.get(key)
14
- if cache[key][:expire] < Time.now.to_i
15
- return cache[key][:value] = nil
16
- else
17
- return cache[key][:value]
18
- end
19
- end
20
- end