inmemory_kv 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWFiZGI1MGRlM2I4MDg3NzFlZGEyYzBkMzAwOWU0MjFkNWY4ZGRiNQ==
4
+ MWU3YjA2NjJmYmQ0ZTg1NWE1NWE5MTBmMDg3YWEzNjUyOTI2ZTFiZQ==
5
5
  data.tar.gz: !binary |-
6
- ZjkxOTg3MTUzOWY0OTM1N2JhOGFiMmNkMDUzYjQ0ODQ3NDg3M2JhOQ==
6
+ Mjk4MWUzN2FhMmE1N2QyOGNjMWFmM2NmMWU1YjBhODcxNmRhNjM0Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzFlNGQ3MmU1ODE1NDI4ZGEyOWU0MTYzYzdjYTlmMTgzMzRiMTM0ZjQ1YzUy
10
- ZjI1MjM0YTBjNTUyMjEwODFhMzVjMmFmM2FlZTUwZmNhOWZkMjdiODUyYWY5
11
- MjUxZDEzZGI4ZjAyNDAwZjI1MGIyNzM2MzVmMTcxOTU3MzI4ZDg=
9
+ N2M4MTRjZmEyZjY5OGYyNDg0YmMxNzAyOWJjMWQ3MDBlMzU1M2M2MzUzODkw
10
+ Njk2OTU4YWZkYmVkZmExNDYzOTJhZWE3YmRiNmQxZWUwYmE1ODIzYjMxOWFl
11
+ MWQ0ODI0YTk0YTQxY2RmNDEzYzFkOWIyYzk2YmEyNTI5ZThhYWM=
12
12
  data.tar.gz: !binary |-
13
- MGVjZWZmMDM5YTQzYmVmMjEyNmU5YjVkYTAxNTExMjllMGJhM2VhNjczMDc0
14
- OWIzYTczMGNmYTBlMzhlMzIwNTI2NDIxN2NmODNjNGJhZTdkZWYxYWY5MzVk
15
- MTYwZjE4MGQ1N2Q2ZDYwYmE3MDI2NGYwNDI0YTZjZWFiZDY5MmI=
13
+ YjdlNDY4M2VjZGE2Njc5MzY2MmFmNjA3YThhYmM1YmRiOGI0NWM0MDgzMjU3
14
+ MDdhYjQzZTgwYTZhNjM0ZjY3NmU2ZTFkYTdkMTM5ZWZjZGU1Nzk1ZjU4ZTNi
15
+ MGUzYTY3ZGJiMTk2ZjAzMDVlNzE2MzZlZjE3M2QwZTJkM2YwZWI=
data/README.md CHANGED
@@ -7,7 +7,7 @@ with LRU built in (a lot like builtin Hash).
7
7
 
8
8
  It doesn't participate in GC and not encounted in. It uses `malloc` for simplicity.
9
9
 
10
- If you do not clone and not mutate it in a fork, than it is as fork-frienly as your malloc is.
10
+ If you do not clone and not mutate it in a fork, than it is as fork-friendly as your malloc is.
11
11
 
12
12
  It is not thread-safe, so protect it by you self. (builtin hash is also not thread-safe)
13
13
 
@@ -32,6 +32,9 @@ Or install it yourself as:
32
32
  ```ruby
33
33
  s2s = InMemoryKV::Str2Str.new
34
34
  s2s['asdf'] = 'qwer'
35
+ s2s.size
36
+ s2s.count
37
+ s2s.empty?
35
38
  s2s.keys
36
39
  s2s.values
37
40
  s2s.entries
@@ -47,6 +50,7 @@ s2s.first # first/oldest entry in LRU
47
50
  s2s.shift # shift oldest entry
48
51
  s2s.data_size # size of key+value entries
49
52
  s2s.total_size # size of key+value entries + internal structures
53
+ s2s.clear
50
54
 
51
55
  # Str2Str is more memory efficient than storing string in a builtin hash
52
56
  # also it is a bit faster.
data/ext/inmemory_kv.c CHANGED
@@ -775,6 +775,15 @@ rb_kv_init_copy(VALUE self, VALUE orig) {
775
775
  return self;
776
776
  }
777
777
 
778
+ static VALUE
779
+ rb_kv_clear(VALUE self) {
780
+ inmemory_kv* kv;
781
+ GetKV(self, kv);
782
+ kv_destroy(kv);
783
+ memset(kv, 0, sizeof(*kv));
784
+ return self;
785
+ }
786
+
778
787
  void
779
788
  Init_inmemory_kv() {
780
789
  VALUE mod_inmemory_kv, cls_str2str;
@@ -805,5 +814,6 @@ Init_inmemory_kv() {
805
814
  rb_define_method(cls_str2str, "each", rb_kv_each, 0);
806
815
  rb_define_method(cls_str2str, "inspect", rb_kv_inspect, 0);
807
816
  rb_define_method(cls_str2str, "initialize_copy", rb_kv_init_copy, 1);
817
+ rb_define_method(cls_str2str, "clear", rb_kv_clear, 0);
808
818
  rb_include_module(cls_str2str, rb_mEnumerable);
809
819
  }
@@ -1,3 +1,3 @@
1
1
  module InMemoryKV
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inmemory_kv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sokolov Yura aka funny_falcon