lru-cache 0.0.1 → 0.0.2

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTI4MjVkOTM1ZmY1ZWJhODM3YTQ1NDZkOWUxY2QzNWIwNWJhOTQzYQ==
4
+ YTEyNTFjMjA2ODVjMzE5OGEyMzgxNTZjNDRlMTk5Njk5MzM2YTNjZg==
5
5
  data.tar.gz: !binary |-
6
- NmMwNzA1YzMwN2FmOTQ2MDllNTA5OTQ3Zjg3ZDljZWM0YWI3MGU4NQ==
6
+ NTBmZmFhYjc2NTY1YzM3MWZkN2YwMzEwMmQ2Yzk2MzRmZjI2MTczYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTM4NGU0NDc5OTY1NjBiMTU2MTNiYzEwMTIyM2VkNjQ4NjMxZGZiNDgwMzdl
10
- ZTQ1YzNkNmVjZTlkMGQ1OTk3MWZlZTgzOGQ0NmYxMDE2YjEwNWM1OGU2NGM0
11
- ZTM4ZGJiMzAzYTE1NTczMDQwNTNiODY2NzU1YWI0OTdkOWNlNGI=
9
+ YzcyYWU0YjVjZGI3Y2Y2MjMzOTk2MWU0YjZjYTNhNmE2NDNlNTVmNTlkYTA5
10
+ OGIzZjg2NjJkMDhhYzI4MzE3NjNjNThlNWM2YzFiYzc0Yjg4MjRkMDNhZTc0
11
+ OGNmOThlODY2N2Y3NzZmZmFmNTIwMTlkMDA1OTExYTViYjFjNmM=
12
12
  data.tar.gz: !binary |-
13
- ZjhkNzYwOThkM2RmMzMwMTkzZGY3Y2Q2NGViZTg3Yzg5OWI5ZTAwYjlkOTYz
14
- NWVlMDVmOGJmOTgyMTIyMGFkNjNhMmY4ZWJhYWViYjNiNzYxMTNlMmJmYWFi
15
- NWI0MjAyYjZkMzRiYTlmNGFhZTVjMjQyZTA4NjhmYjMxODU0ZTk=
13
+ YzIwODA0NTU1ZTRlODc1ZTUwM2VmZDQ2ZTg5Mjk3NmQ0ZGE2YjE4ZDM1ZWU3
14
+ N2U2YTIyNDNmYjNkNzFmYzkwMzRkZjUxODJjMmIzN2ZjNDQxODhhNjYzNjVi
15
+ YzU4NGRjMjM0MGJkNWZiYmRjNGJmNGE5YTI1YzM3MmQwYzk3YTg=
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Lru::Cache
1
+ # LRU::Cache
2
2
 
3
- TODO: Write a gem description
3
+ simple LRU cache
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,12 +18,23 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ ```ruby
22
+ require 'lru/cache'
22
23
 
23
- ## Contributing
24
+ # create a lru cache(size = 10)
25
+ lru = LRU.create 10
24
26
 
25
- 1. Fork it ( https://github.com/[my-github-username]/lru-cache/fork )
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create a new Pull Request
27
+ # set a item
28
+ lru[:k1] = :v1
29
+ lru.set :k2, :v2
30
+
31
+ # get a item
32
+ lru[:k1]
33
+ lru.get :k1
34
+
35
+ # get upper limit
36
+ lru.max
37
+
38
+ # get lru content
39
+ lru.content
40
+ ```
@@ -9,8 +9,7 @@ module LRU
9
9
  end
10
10
 
11
11
  class Cache
12
- attr_reader :content
13
- attr_accessor :max
12
+ attr_reader :content, :max
14
13
 
15
14
  def initialize(max, hash={})
16
15
  @max = max
@@ -1,5 +1,5 @@
1
1
  module LRU
2
2
  class Cache
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -6,13 +6,10 @@ class TestLRU < MiniTest::Unit::TestCase
6
6
  def test_max_accessor
7
7
  lru = LRU.create 10
8
8
  assert_equal lru.max, 10
9
-
10
- lru.max = 5
11
- assert_equal lru.max, 5
12
9
  end
13
10
 
14
11
  def test_content_reader
15
- lru = LRU.create 10
12
+ lru = LRU.create 10
16
13
  lru[:k1] = :v1
17
14
  lru[:k2] = :v2
18
15
  assert_equal lru.content, {:k1 => :v1, :k2 => :v2}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lru-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - wenjun.yan