inmemory_kv 0.1.0 → 0.1.1
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 +8 -8
- data/README.md +5 -1
- data/ext/inmemory_kv.c +10 -0
- data/lib/inmemory_kv/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWU3YjA2NjJmYmQ0ZTg1NWE1NWE5MTBmMDg3YWEzNjUyOTI2ZTFiZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Mjk4MWUzN2FhMmE1N2QyOGNjMWFmM2NmMWU1YjBhODcxNmRhNjM0Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2M4MTRjZmEyZjY5OGYyNDg0YmMxNzAyOWJjMWQ3MDBlMzU1M2M2MzUzODkw
|
10
|
+
Njk2OTU4YWZkYmVkZmExNDYzOTJhZWE3YmRiNmQxZWUwYmE1ODIzYjMxOWFl
|
11
|
+
MWQ0ODI0YTk0YTQxY2RmNDEzYzFkOWIyYzk2YmEyNTI5ZThhYWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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-
|
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
|
}
|
data/lib/inmemory_kv/version.rb
CHANGED