niftie-cachable 0.2.0

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.
Files changed (3) hide show
  1. data/cachable.gemspec +11 -0
  2. data/lib/cachable.rb +28 -0
  3. metadata +54 -0
data/cachable.gemspec ADDED
@@ -0,0 +1,11 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'cachable'
3
+ s.homepage = 'http://github.com/niftie/cachable'
4
+ s.author = 'Nicolas Steenlant'
5
+ s.email = 'nicolas.steenlant@gmail.com'
6
+ s.version = '0.2.0'
7
+ s.date = '2008-11-24'
8
+ s.summary = ''
9
+ s.files = ['cachable.gemspec', 'lib/cachable.rb']
10
+ s.require_path = 'lib'
11
+ end
data/lib/cachable.rb ADDED
@@ -0,0 +1,28 @@
1
+ require 'thread'
2
+
3
+ module Cachable
4
+ STORES = {}
5
+
6
+ def self.extend_object(base)
7
+ STORES[base] = Store.new
8
+ def base.cache
9
+ STORES[self]
10
+ end
11
+ end
12
+
13
+ class Store
14
+ def initialize
15
+ @store = {}
16
+ @mutex = Mutex.new
17
+ end
18
+
19
+ def store(key, object)
20
+ @mutex.synchronize { @store[key] = object }
21
+ end
22
+
23
+ def fetch(key)
24
+ @store[key]
25
+ end
26
+ end
27
+
28
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: niftie-cachable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Nicolas Steenlant
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-24 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: nicolas.steenlant@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - cachable.gemspec
26
+ - lib/cachable.rb
27
+ has_rdoc: false
28
+ homepage: http://github.com/niftie/cachable
29
+ post_install_message:
30
+ rdoc_options: []
31
+
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: "0"
39
+ version:
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ requirements: []
47
+
48
+ rubyforge_project:
49
+ rubygems_version: 1.2.0
50
+ signing_key:
51
+ specification_version: 2
52
+ summary: ""
53
+ test_files: []
54
+