momento 0.1.0 → 0.4.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.release-please-manifest.json +3 -0
- data/.rubocop.yml +26 -1
- data/.ruby-version +1 -1
- data/.yardopts +2 -0
- data/CHANGELOG.md +119 -0
- data/CONTRIBUTING.md +6 -7
- data/Gemfile +1 -6
- data/Gemfile.lock +34 -24
- data/README.md +143 -38
- data/README.template.md +93 -0
- data/examples/.gitignore +1 -0
- data/examples/Gemfile +5 -0
- data/examples/README.md +34 -0
- data/examples/compact.rb +47 -0
- data/examples/example.rb +72 -0
- data/examples/file.rb +58 -0
- data/lib/README-generating-pb.txt +1 -1
- data/lib/momento/auth/credential_provider.rb +78 -0
- data/lib/momento/cache_client.rb +457 -0
- data/lib/momento/collection_ttl.rb +79 -0
- data/lib/momento/config/configuration.rb +16 -0
- data/lib/momento/config/configurations.rb +17 -0
- data/lib/momento/config/transport/grpc_configuration.rb +25 -0
- data/lib/momento/config/transport/static_transport_strategy.rb +12 -0
- data/lib/momento/config/transport/transport_strategy.rb +16 -0
- data/lib/momento/error/grpc_details.rb +38 -0
- data/lib/momento/error/transport_details.rb +20 -0
- data/lib/momento/error/types.rb +247 -0
- data/lib/momento/error.rb +54 -0
- data/lib/momento/error_builder.rb +50 -0
- data/lib/momento/exceptions.rb +7 -0
- data/lib/momento/generated/README.md +16 -0
- data/lib/momento/generated/auth_pb.rb +52 -0
- data/lib/momento/generated/auth_services_pb.rb +27 -0
- data/lib/momento/generated/cacheclient_pb.rb +203 -0
- data/lib/momento/generated/cacheclient_services_pb.rb +90 -0
- data/lib/momento/generated/cacheping_pb.rb +38 -0
- data/lib/momento/generated/cacheping_services_pb.rb +23 -0
- data/lib/momento/generated/cachepubsub_pb.rb +48 -0
- data/lib/momento/generated/cachepubsub_services_pb.rb +56 -0
- data/lib/momento/generated/common_pb.rb +44 -0
- data/lib/momento/generated/controlclient_pb.rb +72 -0
- data/lib/momento/generated/controlclient_services_pb.rb +35 -0
- data/lib/momento/generated/extensions_pb.rb +35 -0
- data/lib/momento/generated/generate_protos.sh +47 -0
- data/lib/momento/generated/leaderboard_pb.rb +56 -0
- data/lib/momento/generated/leaderboard_services_pb.rb +57 -0
- data/lib/momento/generated/permissionmessages_pb.rb +48 -0
- data/lib/momento/generated/token_pb.rb +43 -0
- data/lib/momento/generated/token_services_pb.rb +23 -0
- data/lib/momento/generated/webhook_pb.rb +49 -0
- data/lib/momento/generated/webhook_services_pb.rb +32 -0
- data/lib/momento/{create_cache_response.rb → response/control/create_cache_response.rb} +33 -24
- data/lib/momento/{delete_cache_response.rb → response/control/delete_cache_response.rb} +28 -21
- data/lib/momento/response/control/list_caches_response.rb +80 -0
- data/lib/momento/response/delete_response.rb +45 -0
- data/lib/momento/response/error.rb +10 -3
- data/lib/momento/response/get_response.rb +107 -0
- data/lib/momento/response/response.rb +67 -0
- data/lib/momento/response/response_builder.rb +18 -0
- data/lib/momento/response/set_response.rb +59 -0
- data/lib/momento/response/sort_order.rb +11 -0
- data/lib/momento/response/sorted_set/sorted_set_fetch_response.rb +107 -0
- data/lib/momento/response/sorted_set/sorted_set_put_element_response.rb +44 -0
- data/lib/momento/response/sorted_set/sorted_set_put_elements_response.rb +44 -0
- data/lib/momento/ttl.rb +48 -0
- data/lib/momento/version.rb +2 -1
- data/lib/momento.rb +6 -1
- data/momento.gemspec +6 -3
- data/release-please-config.json +15 -0
- data/sig/momento/auth/credential_provider.rbs +11 -0
- data/sig/momento/cache_client.rbs +12 -0
- data/sig/momento/collection_ttl.rbs +22 -0
- data/sig/momento/config/configuration.rbs +9 -0
- data/sig/momento/config/configurations.rbs +9 -0
- data/sig/momento/config/transport/grpc_configuration.rbs +7 -0
- data/sig/momento/config/transport/transport_strategy.rbs +7 -0
- data/sig/momento/list_caches_response.rbs +7 -0
- data/sig/momento/sorted_set_fetch_response.rbs +13 -0
- data/sig/momento/sorted_set_put_element_response.rbs +5 -0
- data/sig/momento/sorted_set_put_elements_response.rbs +5 -0
- metadata +127 -28
- data/examples/basic.rb +0 -45
- data/lib/momento/cacheclient_pb.rb +0 -332
- data/lib/momento/cacheclient_services_pb.rb +0 -42
- data/lib/momento/controlclient_pb.rb +0 -71
- data/lib/momento/controlclient_services_pb.rb +0 -29
- data/lib/momento/delete_response.rb +0 -33
- data/lib/momento/get_response.rb +0 -80
- data/lib/momento/list_caches_response.rb +0 -53
- data/lib/momento/response.rb +0 -17
- data/lib/momento/set_response.rb +0 -39
- data/lib/momento/simple_cache_client.rb +0 -204
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 616d2ff01199640c05162ca979fb1ab260c1522c8b86a46d34c68ade3f7c430b
|
4
|
+
data.tar.gz: 54e756e639fd2c9fe5b5e004ccb0d1e6d9b6a9368ead7a8b4d518e908100b75a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48f6a80d7798f86b4bcd0d90dc7cb2ba0bec542554e443c2453756cb31b61fbef3f2ff38ad0933b1a71207d45a7782882829247630616605f8dd6d3c5ad68a6d
|
7
|
+
data.tar.gz: ab18d86ce358a2b63d67e953460dddb039c29d01412fddf730a4b55d3210910a1e43c759c78b375cf305c95e6d250f44259d0b6df7f34c1fead22ebbb4e727c7
|
data/.rubocop.yml
CHANGED
@@ -8,16 +8,25 @@ AllCops:
|
|
8
8
|
TargetRubyVersion: 2.7
|
9
9
|
Exclude:
|
10
10
|
# Generated protobuf files
|
11
|
-
- 'lib/**/*
|
11
|
+
- 'lib/momento/generated/**/*'
|
12
12
|
- 'vendor/**/*'
|
13
13
|
|
14
|
+
Layout/ArgumentAlignment:
|
15
|
+
EnforcedStyle: with_fixed_indentation
|
16
|
+
|
14
17
|
Layout/MultilineMethodCallIndentation:
|
15
18
|
EnforcedStyle: indented
|
16
19
|
|
20
|
+
Layout/MultilineMethodCallBraceLayout:
|
21
|
+
EnforcedStyle: new_line
|
22
|
+
|
17
23
|
Lint/AmbiguousBlockAssociation:
|
18
24
|
# For rspec
|
19
25
|
AllowedPatterns: ['change']
|
20
26
|
|
27
|
+
Metrics/MethodLength:
|
28
|
+
Max: 15
|
29
|
+
|
21
30
|
# The rspec defaults are way too tight.
|
22
31
|
RSpec/ExampleLength:
|
23
32
|
Max: 15
|
@@ -25,6 +34,9 @@ RSpec/MultipleExpectations:
|
|
25
34
|
Max: 4
|
26
35
|
RSpec/MultipleMemoizedHelpers:
|
27
36
|
Max: 10
|
37
|
+
# I disagree with this one. It should be clear you're using the subject.
|
38
|
+
RSpec/NamedSubject:
|
39
|
+
Enabled: false
|
28
40
|
RSpec/NestedGroups:
|
29
41
|
Max: 4
|
30
42
|
|
@@ -59,3 +71,16 @@ Style/WordArray:
|
|
59
71
|
|
60
72
|
Layout/LineLength:
|
61
73
|
Max: 120
|
74
|
+
Exclude:
|
75
|
+
- 'lib/momento/generated/**/*'
|
76
|
+
|
77
|
+
Style/Documentation:
|
78
|
+
Exclude:
|
79
|
+
- 'lib/momento/generated/**/*'
|
80
|
+
|
81
|
+
Metrics/ModuleLength:
|
82
|
+
Exclude:
|
83
|
+
- 'lib/momento/generated/**/*'
|
84
|
+
|
85
|
+
RSpec/FactoryBot/FactoryClassName:
|
86
|
+
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.2.2
|
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [0.4.9](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.8...momento/v0.4.9) (2024-04-30)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* remove token and specify email for the redundant tag ([#168](https://github.com/momentohq/client-sdk-ruby/issues/168)) ([c119376](https://github.com/momentohq/client-sdk-ruby/commit/c11937641acce6b55dbb7e59f87f548769ad9313))
|
9
|
+
|
10
|
+
## [0.4.8](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.7...momento/v0.4.8) (2024-04-30)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* check out the repo with the machine user token ([#166](https://github.com/momentohq/client-sdk-ruby/issues/166)) ([67845af](https://github.com/momentohq/client-sdk-ruby/commit/67845af1da172271ea0e604d4ab8d6e749a7d7c1))
|
16
|
+
|
17
|
+
## [0.4.7](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.6...momento/v0.4.7) (2024-04-30)
|
18
|
+
|
19
|
+
|
20
|
+
### Bug Fixes
|
21
|
+
|
22
|
+
* update the grpc dependency ([#164](https://github.com/momentohq/client-sdk-ruby/issues/164)) ([00c0ee5](https://github.com/momentohq/client-sdk-ruby/commit/00c0ee578c63b2003b6de23506715447d762997a))
|
23
|
+
|
24
|
+
## [0.4.6](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.5...momento/v0.4.6) (2024-04-30)
|
25
|
+
|
26
|
+
|
27
|
+
### Bug Fixes
|
28
|
+
|
29
|
+
* check for local changes on release please failure ([#162](https://github.com/momentohq/client-sdk-ruby/issues/162)) ([bf8322c](https://github.com/momentohq/client-sdk-ruby/commit/bf8322c2cbd887c595db537838e227a0e66ebeb3))
|
30
|
+
|
31
|
+
## [0.4.5](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.4...momento/v0.4.5) (2024-04-30)
|
32
|
+
|
33
|
+
|
34
|
+
### Bug Fixes
|
35
|
+
|
36
|
+
* check for local changes after publishing the gem ([#160](https://github.com/momentohq/client-sdk-ruby/issues/160)) ([cd9f242](https://github.com/momentohq/client-sdk-ruby/commit/cd9f242d224b6541d11fe06df23311d7ee6f19d0))
|
37
|
+
|
38
|
+
## [0.4.4](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.3...momento/v0.4.4) (2024-04-30)
|
39
|
+
|
40
|
+
|
41
|
+
### Bug Fixes
|
42
|
+
|
43
|
+
* separate 'bundle install' to see if it modifies the checkout ([#158](https://github.com/momentohq/client-sdk-ruby/issues/158)) ([dbb5d20](https://github.com/momentohq/client-sdk-ruby/commit/dbb5d20619fb556eeebec7f80ff55e02bd14c282))
|
44
|
+
|
45
|
+
## [0.4.3](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.2...momento/v0.4.3) (2024-04-30)
|
46
|
+
|
47
|
+
|
48
|
+
### Bug Fixes
|
49
|
+
|
50
|
+
* verbose rubygems publishing ([#156](https://github.com/momentohq/client-sdk-ruby/issues/156)) ([0f6ec1f](https://github.com/momentohq/client-sdk-ruby/commit/0f6ec1fc958bb9473b4f508f2cb2d1e35beaf90c))
|
51
|
+
|
52
|
+
## [0.4.2](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.1...momento/v0.4.2) (2024-04-30)
|
53
|
+
|
54
|
+
|
55
|
+
### Bug Fixes
|
56
|
+
|
57
|
+
* add git status for release-please troubleshooting ([#154](https://github.com/momentohq/client-sdk-ruby/issues/154)) ([115b4ef](https://github.com/momentohq/client-sdk-ruby/commit/115b4ef77c62344e1debd813d19adf47fa687f1b))
|
58
|
+
|
59
|
+
## [0.4.1](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.0...momento/v0.4.1) (2024-04-29)
|
60
|
+
|
61
|
+
|
62
|
+
### Bug Fixes
|
63
|
+
|
64
|
+
* Update release please action versions ([#152](https://github.com/momentohq/client-sdk-ruby/issues/152)) ([c4241da](https://github.com/momentohq/client-sdk-ruby/commit/c4241daa72dcb1f73eafef9ef86618e51826c3fb))
|
65
|
+
|
66
|
+
## [0.4.0](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.3.0...momento/v0.4.0) (2024-04-29)
|
67
|
+
|
68
|
+
|
69
|
+
### Features
|
70
|
+
|
71
|
+
* add a CredentialProvider ([#134](https://github.com/momentohq/client-sdk-ruby/issues/134)) ([c74f34a](https://github.com/momentohq/client-sdk-ruby/commit/c74f34a102d24b6f143376ac4c643139b2559394))
|
72
|
+
* add a value alias in sorted_set_fetch ([#149](https://github.com/momentohq/client-sdk-ruby/issues/149)) ([f310df0](https://github.com/momentohq/client-sdk-ruby/commit/f310df08735a41bd834e27ef138897c2ac5aa5ce))
|
73
|
+
* add cache config objects as CacheClient argument ([f8c1c86](https://github.com/momentohq/client-sdk-ruby/commit/f8c1c860fa05c83a766b0063835013b32cc35382))
|
74
|
+
* add cache config objects as CacheClient argument ([#142](https://github.com/momentohq/client-sdk-ruby/issues/142)) ([1158039](https://github.com/momentohq/client-sdk-ruby/commit/1158039ab4caa8fb6ab491c71c82d9eae3ad4083))
|
75
|
+
* add sorted set put and fetch by score ([#147](https://github.com/momentohq/client-sdk-ruby/issues/147)) ([a8fd259](https://github.com/momentohq/client-sdk-ruby/commit/a8fd259d09f273a3ed0c857b05610534d801673e))
|
76
|
+
* rename SimpleCacheClient to CacheClient ([37e2183](https://github.com/momentohq/client-sdk-ruby/commit/37e2183390e3184ad6ce4429df15fdd4b8b15a74))
|
77
|
+
* rename SimpleCacheClient to CacheClient ([#141](https://github.com/momentohq/client-sdk-ruby/issues/141)) ([f1e6d86](https://github.com/momentohq/client-sdk-ruby/commit/f1e6d86ea9665bb66164265a7baa85f729d798a8))
|
78
|
+
* support UTF-8 cache names instead of just ASCII ([#148](https://github.com/momentohq/client-sdk-ruby/issues/148)) ([5627f52](https://github.com/momentohq/client-sdk-ruby/commit/5627f526ccb269383289f8b3a033890f868f936d))
|
79
|
+
|
80
|
+
|
81
|
+
### Bug Fixes
|
82
|
+
|
83
|
+
* change the ruby versions in the test action to strings ([4700338](https://github.com/momentohq/client-sdk-ruby/commit/47003387cbab0739361eedcdad9662f0a0753757))
|
84
|
+
* change the ruby versions in the test action to strings ([#136](https://github.com/momentohq/client-sdk-ruby/issues/136)) ([975be89](https://github.com/momentohq/client-sdk-ruby/commit/975be891c7cea139b6365698cf80d74db718bc3f))
|
85
|
+
* fill out credential provider method docs ([#151](https://github.com/momentohq/client-sdk-ruby/issues/151)) ([90a8a39](https://github.com/momentohq/client-sdk-ruby/commit/90a8a39a50c908cc927fbdb8307fb50d29d7b960))
|
86
|
+
|
87
|
+
## [0.3.0](https://github.com/momentohq/client-sdk-ruby/compare/momento-v0.2.0...momento/v0.3.0) (2023-11-09)
|
88
|
+
|
89
|
+
|
90
|
+
### Features
|
91
|
+
|
92
|
+
* add support for v1 tokens ([0a98c34](https://github.com/momentohq/client-sdk-ruby/commit/0a98c3404972966a7c4c2017908f2c204532712d))
|
93
|
+
|
94
|
+
## [0.2.0](https://github.com/momentohq/client-sdk-ruby/compare/momento-v0.1.0...momento/v0.2.0) (2022-12-07)
|
95
|
+
|
96
|
+
### Breaking Changes
|
97
|
+
|
98
|
+
* TTLs are now in seconds.
|
99
|
+
* `response.value` was split into `response.value_bytes` and `response.value_string`
|
100
|
+
* Stringifying a Momento::GetResponse no longer gives you the value.
|
101
|
+
* `response.exception` is now `response.error.cause`
|
102
|
+
|
103
|
+
### Features
|
104
|
+
|
105
|
+
* Momento::Responses now stringfy with useful information.
|
106
|
+
* `response.error` is a real Exception and can be raised
|
107
|
+
* `response.error` is now a Momento::Error with expanded error information.
|
108
|
+
* nil and non-String keys, values, and cache names are now TypeErrors.
|
109
|
+
* Non-ASCII cache names are now InvalidArgument responses.
|
110
|
+
* An invalid TTL will raise ArgumentError.
|
111
|
+
* All response methods are discoverable in an IDE.
|
112
|
+
* Improve the README
|
113
|
+
* Complete YARD class and method documentation
|
114
|
+
* More examples, and instructions how to run them.
|
115
|
+
* Document how error handling works.
|
116
|
+
|
117
|
+
## 0.1.0 (2022-11-21)
|
118
|
+
|
119
|
+
First release.
|
data/CONTRIBUTING.md
CHANGED
@@ -36,17 +36,16 @@ This will install both the runtime and development dependencies.
|
|
36
36
|
|
37
37
|
## Trying it out
|
38
38
|
|
39
|
-
You can run code from the repository's `lib/` directory by adding `-Ilib` to your ruby commands. For example, `ruby -Ilib examples/
|
39
|
+
You can run code from the repository's `lib/` directory by adding `-Ilib` to your ruby commands. For example, `ruby -Ilib examples/example.rb` or `irb -Ilib`. This will use the repository's code even if you have the gem installed.
|
40
40
|
|
41
41
|
You can also build a gem from local sources and install it. Run `bundle exec rake install`.
|
42
42
|
|
43
|
-
## Running
|
43
|
+
## Running tests
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
TODO
|
45
|
+
You will need a momento API key that you can generate on the [Momento Console](https://console.gomomento.com/api-keys).
|
46
|
+
1. Set the environment variable `MOMENTO_API_KEY` to your Momento API key.
|
47
|
+
2. Optionally set the environment variable `TEST_CACHE_NAME` to a cache that is safe to test with and delete. If you don't do this, the cache 'ruby-test-cache' will be used by default.
|
48
|
+
3. Run `rspec` from the command line to execute the tests.
|
50
49
|
|
51
50
|
## Bug reports
|
52
51
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
momento (0.
|
5
|
-
grpc (~> 1)
|
6
|
-
jwt (~> 2)
|
4
|
+
momento (0.4.9)
|
5
|
+
grpc (~> 1.62)
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: https://rubygems.org/
|
@@ -23,15 +22,19 @@ GEM
|
|
23
22
|
activesupport (>= 5.0.0)
|
24
23
|
faker (3.0.0)
|
25
24
|
i18n (>= 1.8.11, < 2)
|
26
|
-
google-protobuf (3.
|
27
|
-
google-protobuf (3.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
google-protobuf (3.25.3-arm64-darwin)
|
26
|
+
google-protobuf (3.25.3-x86_64-darwin)
|
27
|
+
google-protobuf (3.25.3-x86_64-linux)
|
28
|
+
googleapis-common-protos-types (1.14.0)
|
29
|
+
google-protobuf (~> 3.18)
|
30
|
+
grpc (1.62.0-arm64-darwin)
|
31
|
+
google-protobuf (~> 3.25)
|
32
32
|
googleapis-common-protos-types (~> 1.0)
|
33
|
-
grpc (1.
|
34
|
-
google-protobuf (~> 3.
|
33
|
+
grpc (1.62.0-x86_64-darwin)
|
34
|
+
google-protobuf (~> 3.25)
|
35
|
+
googleapis-common-protos-types (~> 1.0)
|
36
|
+
grpc (1.62.0-x86_64-linux)
|
37
|
+
google-protobuf (~> 3.25)
|
35
38
|
googleapis-common-protos-types (~> 1.0)
|
36
39
|
i18n (1.12.0)
|
37
40
|
concurrent-ruby (~> 1.0)
|
@@ -52,19 +55,19 @@ GEM
|
|
52
55
|
rake (13.0.6)
|
53
56
|
regexp_parser (2.6.0)
|
54
57
|
rexml (3.2.5)
|
55
|
-
rspec (3.
|
56
|
-
rspec-core (~> 3.
|
57
|
-
rspec-expectations (~> 3.
|
58
|
-
rspec-mocks (~> 3.
|
59
|
-
rspec-core (3.
|
60
|
-
rspec-support (~> 3.
|
61
|
-
rspec-expectations (3.
|
58
|
+
rspec (3.12.0)
|
59
|
+
rspec-core (~> 3.12.0)
|
60
|
+
rspec-expectations (~> 3.12.0)
|
61
|
+
rspec-mocks (~> 3.12.0)
|
62
|
+
rspec-core (3.12.0)
|
63
|
+
rspec-support (~> 3.12.0)
|
64
|
+
rspec-expectations (3.12.0)
|
62
65
|
diff-lcs (>= 1.2.0, < 2.0)
|
63
|
-
rspec-support (~> 3.
|
64
|
-
rspec-mocks (3.
|
66
|
+
rspec-support (~> 3.12.0)
|
67
|
+
rspec-mocks (3.12.0)
|
65
68
|
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
-
rspec-support (~> 3.
|
67
|
-
rspec-support (3.
|
69
|
+
rspec-support (~> 3.12.0)
|
70
|
+
rspec-support (3.12.0)
|
68
71
|
rubocop (1.38.0)
|
69
72
|
json (~> 2.3)
|
70
73
|
parallel (~> 1.10)
|
@@ -94,8 +97,13 @@ GEM
|
|
94
97
|
tzinfo (2.0.5)
|
95
98
|
concurrent-ruby (~> 1.0)
|
96
99
|
unicode-display_width (2.3.0)
|
100
|
+
webrick (1.7.0)
|
101
|
+
yard (0.9.28)
|
102
|
+
webrick (~> 1.7.0)
|
97
103
|
|
98
104
|
PLATFORMS
|
105
|
+
arm64-darwin-22
|
106
|
+
arm64-darwin-23
|
99
107
|
x86_64-darwin-20
|
100
108
|
x86_64-darwin-21
|
101
109
|
x86_64-linux
|
@@ -104,15 +112,17 @@ DEPENDENCIES
|
|
104
112
|
bundler (~> 2.3)
|
105
113
|
factory_bot (~> 6.2.1)
|
106
114
|
faker (~> 3.0)
|
115
|
+
jwt (~> 2)
|
107
116
|
momento!
|
108
|
-
pry-byebug
|
117
|
+
pry-byebug (~> 3)
|
109
118
|
rake (~> 13.0)
|
110
|
-
rspec (~> 3.
|
119
|
+
rspec (~> 3.12)
|
111
120
|
rubocop (~> 1.38)
|
112
121
|
rubocop-performance (~> 1.15)
|
113
122
|
rubocop-rake (~> 0.6.0)
|
114
123
|
rubocop-rspec (~> 2.15)
|
115
124
|
simplecov (~> 0.21)
|
125
|
+
yard (~> 0.9)
|
116
126
|
|
117
127
|
BUNDLED WITH
|
118
128
|
2.3.24
|
data/README.md
CHANGED
@@ -1,80 +1,185 @@
|
|
1
|
-
|
1
|
+
<head>
|
2
|
+
<meta name="Momento Ruby Client Library Documentation" content="Ruby client software development kit for Momento Cache">
|
3
|
+
</head>
|
4
|
+
<img src="https://docs.momentohq.com/img/momento-logo-forest.svg" alt="logo" width="400"/>
|
2
5
|
|
3
|
-
|
6
|
+
[![project status](https://momentohq.github.io/standards-and-practices/badges/project-status-official.svg)](https://github.com/momentohq/standards-and-practices/blob/main/docs/momento-on-github.md)
|
7
|
+
[![project stability](https://momentohq.github.io/standards-and-practices/badges/project-stability-beta.svg)](https://github.com/momentohq/standards-and-practices/blob/main/docs/momento-on-github.md)
|
4
8
|
|
5
|
-
|
9
|
+
# Momento Ruby Client Library
|
10
|
+
|
11
|
+
Momento Cache is a fast, simple, pay-as-you-go caching solution without any of the operational overhead
|
12
|
+
required by traditional caching solutions. This repo contains the source code for the Momento Ruby client library.
|
13
|
+
|
14
|
+
To get started with Momento you will need a Momento Auth Token. You can get one from the [Momento Console](https://console.gomomento.com).
|
15
|
+
|
16
|
+
* Website: [https://www.gomomento.com/](https://www.gomomento.com/)
|
17
|
+
* Momento Documentation: [https://docs.momentohq.com/](https://docs.momentohq.com/)
|
18
|
+
* Getting Started: [https://docs.momentohq.com/getting-started](https://docs.momentohq.com/getting-started)
|
19
|
+
* Ruby SDK Documentation: [https://docs.momentohq.com/sdks/ruby](https://docs.momentohq.com/sdks/ruby)
|
20
|
+
* Discuss: [Momento Discord](https://discord.gg/3HkAKjUZGq)
|
21
|
+
|
22
|
+
# Momento Ruby SDK
|
23
|
+
|
24
|
+
To get started with Momento you will need a Momento API key. You can get one from the [Momento Console](https://console.gomomento.com/api-keys).
|
25
|
+
|
26
|
+
* Website: [https://www.gomomento.com/](https://www.gomomento.com/)
|
27
|
+
* Momento Documentation: [https://docs.momentohq.com/](https://docs.momentohq.com/)
|
28
|
+
* Getting Started: [https://docs.momentohq.com/getting-started](https://docs.momentohq.com/getting-started)
|
29
|
+
* Discuss: [Momento Discord](https://discord.gg/3HkAKjUZGq)
|
30
|
+
|
31
|
+
## Packages
|
32
|
+
|
33
|
+
The Momento Ruby SDK is available on [RubyGems](https://rubygems.org/gems/momento)
|
6
34
|
|
7
35
|
Install the gem and add to an application's Gemfile by executing:
|
8
36
|
|
9
|
-
|
37
|
+
```sh
|
38
|
+
bundle add momento
|
39
|
+
```
|
10
40
|
|
11
41
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
42
|
|
13
|
-
|
43
|
+
```sh
|
44
|
+
gem install momento
|
45
|
+
```
|
46
|
+
|
47
|
+
You will need Ruby 2.7 or newer.
|
14
48
|
|
15
|
-
|
49
|
+
An IDE with good Ruby support, such as [RubyMine](https://www.jetbrains.com/ruby/), is recommended.
|
16
50
|
|
17
|
-
If you're using an M1 or M2 Mac,
|
51
|
+
**Note: M1 or M2 Macs**: If you're using an M1 or M2 Mac, you may have trouble installing the `grpc` gem; [see this issue for more information](https://github.com/grpc/grpc/issues/31215).
|
18
52
|
|
19
53
|
[A work around](https://github.com/grpc/grpc/pull/31151#issuecomment-1310321807) is to run `bundle config build.grpc --with-ldflags="-Wl,-undefined,dynamic_lookup"` before doing `bundle install`.
|
20
54
|
|
21
|
-
##
|
55
|
+
## Usage
|
22
56
|
|
23
|
-
|
24
|
-
* Ruby >= 2.7
|
57
|
+
You can find this example code and more in [the examples directory](./examples) of this repository.
|
25
58
|
|
26
|
-
|
59
|
+
```ruby
|
60
|
+
# An example of the basic functionality of
|
61
|
+
# Momento::CacheClient.
|
27
62
|
|
28
|
-
```
|
29
63
|
require 'momento'
|
30
64
|
|
31
|
-
#
|
32
|
-
|
65
|
+
# Cached items will be deleted after 12.5 seconds.
|
66
|
+
TTL_SECONDS = 12.5
|
67
|
+
|
68
|
+
# The name of the cache to create *and delete*
|
69
|
+
CACHE_NAME = ENV.fetch('MOMENTO_CACHE_NAME')
|
33
70
|
|
34
|
-
#
|
35
|
-
|
71
|
+
# Create a credential provider that loads a Momento API Key from an environment variable.
|
72
|
+
credential_provider = Momento::CredentialProvider.from_env_var('MOMENTO_API_KEY')
|
36
73
|
|
37
74
|
# Instantiate a Momento client.
|
38
|
-
client = Momento::
|
39
|
-
|
40
|
-
|
75
|
+
client = Momento::CacheClient.new(
|
76
|
+
configuration: Momento::Cache::Configurations::Laptop.latest,
|
77
|
+
credential_provider: credential_provider,
|
78
|
+
default_ttl: TTL_SECONDS
|
41
79
|
)
|
42
80
|
|
43
|
-
# Create a cache
|
44
|
-
response = client.create_cache(
|
45
|
-
if response.success?
|
46
|
-
puts "Created the cache
|
81
|
+
# Create a cache to play with.
|
82
|
+
response = client.create_cache(CACHE_NAME)
|
83
|
+
if response.success?
|
84
|
+
puts "Created the cache."
|
85
|
+
elsif response.already_exists?
|
86
|
+
puts "Cache already exists."
|
47
87
|
elsif response.error?
|
48
|
-
raise "Couldn't create a cache: #{response}"
|
49
|
-
|
50
|
-
|
88
|
+
raise "Couldn't create a cache: #{response.error}"
|
89
|
+
end
|
90
|
+
|
91
|
+
# List our caches.
|
92
|
+
response = client.list_caches
|
93
|
+
if response.success?
|
94
|
+
puts "Caches: #{response.cache_names&.join(", ")}"
|
95
|
+
elsif response.error?
|
96
|
+
raise "Couldn't list the caches: #{response.error}"
|
51
97
|
end
|
52
98
|
|
53
99
|
# Put an item in the cache.
|
54
|
-
response = client.set(
|
100
|
+
response = client.set(CACHE_NAME, "key", "You cached something!")
|
55
101
|
if response.success?
|
56
102
|
puts "Set an item in the cache."
|
57
103
|
elsif response.error?
|
58
|
-
raise "Couldn't set an item in the cache: #{response}"
|
59
|
-
else
|
60
|
-
raise
|
104
|
+
raise "Couldn't set an item in the cache: #{response.error}"
|
61
105
|
end
|
62
106
|
|
63
107
|
# And get it back.
|
64
|
-
response = client.get(
|
108
|
+
response = client.get(CACHE_NAME, "key")
|
65
109
|
if response.hit?
|
66
|
-
puts "Cache returned: #{response.
|
110
|
+
puts "Cache returned: #{response.value_string}"
|
67
111
|
elsif response.miss?
|
68
112
|
puts "The item wasn't found in the cache."
|
69
113
|
elsif response.error?
|
70
|
-
raise "Couldn't get an item from the cache: #{response}"
|
71
|
-
|
72
|
-
|
114
|
+
raise "Couldn't get an item from the cache: #{response.error}"
|
115
|
+
end
|
116
|
+
|
117
|
+
# Now delete it.
|
118
|
+
response = client.delete(CACHE_NAME, "key")
|
119
|
+
if response.success?
|
120
|
+
puts "Key/value deleted."
|
121
|
+
elsif response.error?
|
122
|
+
raise "Couldn't delete an item from the cache: #{response.error}"
|
123
|
+
end
|
124
|
+
|
125
|
+
# And delete our test cache.
|
126
|
+
response = client.delete_cache(CACHE_NAME)
|
127
|
+
if response.success?
|
128
|
+
puts "Deleted the cache."
|
129
|
+
elsif response.error?
|
130
|
+
raise "Couldn't create a cache: #{response.error}"
|
73
131
|
end
|
132
|
+
|
74
133
|
```
|
75
134
|
|
76
|
-
|
135
|
+
## Getting Started and Documentation
|
136
|
+
|
137
|
+
General documentation on Momento and the Momento SDKs is available on the [Momento Docs website](https://docs.momentohq.com/). Specific usage examples for the Ruby SDK are coming soon!
|
138
|
+
|
139
|
+
## Examples
|
140
|
+
|
141
|
+
Check out full working code in the [example](./example/) directory of this repository!
|
142
|
+
|
143
|
+
## Error Handling
|
144
|
+
|
145
|
+
[Momento::CacheClient](https://github.com/momentohq/client-sdk-ruby/blob/main/lib/momento/cache_client.rb) follows the philosophy that when working with a service,
|
146
|
+
[exceptions are bugs](https://www.gomomento.com/blog/exceptions-are-bugs). Minor outages are a fact of life; they are normal rather than exceptional.
|
147
|
+
|
148
|
+
When there is a problem, Momento::CacheClient methods return an error response, the same as any other response. This makes errors more visible, allows your IDE to be more helpful in ensuring that you've handled the responses you care about.
|
149
|
+
|
150
|
+
Check if a response is an error with `response.error?`, get the error with `response.error`, and it can be raised as an exception with `raise response.error`. Generally, printing `response.error` tell you what you need to know, but you might want more details. Here's a contrived example.
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
# This is an invalid cache name. They must be ASCII-only.
|
154
|
+
cache_name = 'çåché nåme'
|
155
|
+
response = client.create_cache(cache_name)
|
156
|
+
if response.success?
|
157
|
+
puts "Created the cache"
|
158
|
+
elsif response.error?
|
159
|
+
error = response.error
|
160
|
+
puts "Creating the cache failed: #{error}"
|
161
|
+
case error
|
162
|
+
when Momento::Error::LimitExceededError
|
163
|
+
puts "We'll have to slow down"
|
164
|
+
when Momento::Error::PermissionError
|
165
|
+
puts "We'll have to fix our auth token"
|
166
|
+
when Momento::Error::InvalidArgumentError
|
167
|
+
puts "We can't make a cache named #{cache_name}"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
```
|
171
|
+
|
172
|
+
Momento::CacheClient *will* raise exceptions for programmer mistakes such as passing the wrong type, typically an ArgumentError or TypeError. The exceptions are documented for each method.
|
173
|
+
|
174
|
+
See [Momento::Response](https://github.com/momentohq/client-sdk-ruby/blob/main/lib/momento/response.rb) for more about working with with error responses, and [Momento::Error](https://github.com/momentohq/client-sdk-ruby/blob/main/lib/momento/error.rb) for more about using errors.
|
175
|
+
|
176
|
+
## Issues
|
177
|
+
|
178
|
+
Please report any bugs, issues, requests, and feedback via this repo's [issue tracker](https://github.com/momentohq/client-sdk-ruby/issues).
|
179
|
+
|
180
|
+
## Developing
|
77
181
|
|
78
|
-
|
182
|
+
If you are interested in contributing to the SDK, please see the [CONTRIBUTING](./CONTRIBUTING.md) docs.
|
79
183
|
|
80
|
-
|
184
|
+
----------------------------------------------------------------------------------------
|
185
|
+
For more info, visit our website at [https://gomomento.com](https://gomomento.com)!
|
data/README.template.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
{{ ossHeader }}
|
2
|
+
|
3
|
+
# Momento Ruby SDK
|
4
|
+
|
5
|
+
To get started with Momento you will need a Momento API key. You can get one from the [Momento Console](https://console.gomomento.com/api-keys).
|
6
|
+
|
7
|
+
* Website: [https://www.gomomento.com/](https://www.gomomento.com/)
|
8
|
+
* Momento Documentation: [https://docs.momentohq.com/](https://docs.momentohq.com/)
|
9
|
+
* Getting Started: [https://docs.momentohq.com/getting-started](https://docs.momentohq.com/getting-started)
|
10
|
+
* Discuss: [Momento Discord](https://discord.gg/3HkAKjUZGq)
|
11
|
+
|
12
|
+
## Packages
|
13
|
+
|
14
|
+
The Momento Ruby SDK is available on [RubyGems](https://rubygems.org/gems/momento)
|
15
|
+
|
16
|
+
Install the gem and add to an application's Gemfile by executing:
|
17
|
+
|
18
|
+
```sh
|
19
|
+
bundle add momento
|
20
|
+
```
|
21
|
+
|
22
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
23
|
+
|
24
|
+
```sh
|
25
|
+
gem install momento
|
26
|
+
```
|
27
|
+
|
28
|
+
You will need Ruby 2.7 or newer.
|
29
|
+
|
30
|
+
An IDE with good Ruby support, such as [RubyMine](https://www.jetbrains.com/ruby/), is recommended.
|
31
|
+
|
32
|
+
**Note: M1 or M2 Macs**: If you're using an M1 or M2 Mac, you may have trouble installing the `grpc` gem; [see this issue for more information](https://github.com/grpc/grpc/issues/31215).
|
33
|
+
|
34
|
+
[A work around](https://github.com/grpc/grpc/pull/31151#issuecomment-1310321807) is to run `bundle config build.grpc --with-ldflags="-Wl,-undefined,dynamic_lookup"` before doing `bundle install`.
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
You can find this example code and more in [the examples directory](./examples) of this repository.
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
{% include "./examples/example.rb" %}
|
42
|
+
```
|
43
|
+
|
44
|
+
## Getting Started and Documentation
|
45
|
+
|
46
|
+
General documentation on Momento and the Momento SDKs is available on the [Momento Docs website](https://docs.momentohq.com/). Specific usage examples for the Ruby SDK are coming soon!
|
47
|
+
|
48
|
+
## Examples
|
49
|
+
|
50
|
+
Check out full working code in the [example](./example/) directory of this repository!
|
51
|
+
|
52
|
+
## Error Handling
|
53
|
+
|
54
|
+
[Momento::CacheClient](https://github.com/momentohq/client-sdk-ruby/blob/main/lib/momento/cache_client.rb) follows the philosophy that when working with a service,
|
55
|
+
[exceptions are bugs](https://www.gomomento.com/blog/exceptions-are-bugs). Minor outages are a fact of life; they are normal rather than exceptional.
|
56
|
+
|
57
|
+
When there is a problem, Momento::CacheClient methods return an error response, the same as any other response. This makes errors more visible, allows your IDE to be more helpful in ensuring that you've handled the responses you care about.
|
58
|
+
|
59
|
+
Check if a response is an error with `response.error?`, get the error with `response.error`, and it can be raised as an exception with `raise response.error`. Generally, printing `response.error` tell you what you need to know, but you might want more details. Here's a contrived example.
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
# This is an invalid cache name. They must be ASCII-only.
|
63
|
+
cache_name = 'çåché nåme'
|
64
|
+
response = client.create_cache(cache_name)
|
65
|
+
if response.success?
|
66
|
+
puts "Created the cache"
|
67
|
+
elsif response.error?
|
68
|
+
error = response.error
|
69
|
+
puts "Creating the cache failed: #{error}"
|
70
|
+
case error
|
71
|
+
when Momento::Error::LimitExceededError
|
72
|
+
puts "We'll have to slow down"
|
73
|
+
when Momento::Error::PermissionError
|
74
|
+
puts "We'll have to fix our auth token"
|
75
|
+
when Momento::Error::InvalidArgumentError
|
76
|
+
puts "We can't make a cache named #{cache_name}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
Momento::CacheClient *will* raise exceptions for programmer mistakes such as passing the wrong type, typically an ArgumentError or TypeError. The exceptions are documented for each method.
|
82
|
+
|
83
|
+
See [Momento::Response](https://github.com/momentohq/client-sdk-ruby/blob/main/lib/momento/response.rb) for more about working with with error responses, and [Momento::Error](https://github.com/momentohq/client-sdk-ruby/blob/main/lib/momento/error.rb) for more about using errors.
|
84
|
+
|
85
|
+
## Issues
|
86
|
+
|
87
|
+
Please report any bugs, issues, requests, and feedback via this repo's [issue tracker](https://github.com/momentohq/client-sdk-ruby/issues).
|
88
|
+
|
89
|
+
## Developing
|
90
|
+
|
91
|
+
If you are interested in contributing to the SDK, please see the [CONTRIBUTING](./CONTRIBUTING.md) docs.
|
92
|
+
|
93
|
+
{{ ossFooter }}
|
data/examples/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
test_copy.jpg
|