momento 0.2.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.release-please-manifest.json +1 -1
  3. data/.rubocop.yml +14 -1
  4. data/.ruby-version +1 -1
  5. data/CHANGELOG.md +105 -0
  6. data/CONTRIBUTING.md +5 -6
  7. data/Gemfile +1 -6
  8. data/Gemfile.lock +34 -28
  9. data/README.md +64 -44
  10. data/README.template.md +30 -25
  11. data/examples/.gitignore +1 -0
  12. data/examples/Gemfile +1 -1
  13. data/examples/README.md +5 -6
  14. data/examples/compact.rb +13 -9
  15. data/examples/example.rb +24 -8
  16. data/examples/file.rb +7 -6
  17. data/lib/README-generating-pb.txt +1 -1
  18. data/lib/momento/auth/credential_provider.rb +78 -0
  19. data/lib/momento/cache_client.rb +478 -0
  20. data/lib/momento/collection_ttl.rb +79 -0
  21. data/lib/momento/config/configuration.rb +42 -0
  22. data/lib/momento/config/configurations.rb +24 -0
  23. data/lib/momento/config/transport/grpc_configuration.rb +35 -0
  24. data/lib/momento/config/transport/static_transport_strategy.rb +12 -0
  25. data/lib/momento/config/transport/transport_strategy.rb +16 -0
  26. data/lib/momento/error/types.rb +22 -0
  27. data/lib/momento/generated/README.md +16 -0
  28. data/lib/momento/generated/auth_pb.rb +52 -0
  29. data/lib/momento/generated/auth_services_pb.rb +27 -0
  30. data/lib/momento/generated/cacheclient_pb.rb +203 -0
  31. data/lib/momento/generated/cacheclient_services_pb.rb +90 -0
  32. data/lib/momento/generated/cacheping_pb.rb +38 -0
  33. data/lib/momento/generated/cacheping_services_pb.rb +23 -0
  34. data/lib/momento/generated/cachepubsub_pb.rb +48 -0
  35. data/lib/momento/generated/cachepubsub_services_pb.rb +56 -0
  36. data/lib/momento/generated/common_pb.rb +44 -0
  37. data/lib/momento/generated/controlclient_pb.rb +72 -0
  38. data/lib/momento/generated/controlclient_services_pb.rb +35 -0
  39. data/lib/momento/generated/extensions_pb.rb +35 -0
  40. data/lib/momento/generated/generate_protos.sh +47 -0
  41. data/lib/momento/generated/leaderboard_pb.rb +56 -0
  42. data/lib/momento/generated/leaderboard_services_pb.rb +57 -0
  43. data/lib/momento/generated/permissionmessages_pb.rb +48 -0
  44. data/lib/momento/generated/token_pb.rb +43 -0
  45. data/lib/momento/generated/token_services_pb.rb +23 -0
  46. data/lib/momento/generated/webhook_pb.rb +49 -0
  47. data/lib/momento/generated/webhook_services_pb.rb +32 -0
  48. data/lib/momento/response/control/create_cache_response.rb +61 -0
  49. data/lib/momento/{delete_cache_response_builder.rb → response/control/delete_cache_response.rb} +24 -3
  50. data/lib/momento/response/control/list_caches_response.rb +80 -0
  51. data/lib/momento/{delete_response_builder.rb → response/delete_response.rb} +24 -2
  52. data/lib/momento/{get_response.rb → response/get_response.rb} +39 -9
  53. data/lib/momento/{response.rb → response/response.rb} +11 -14
  54. data/lib/momento/response/set_response.rb +59 -0
  55. data/lib/momento/response/sort_order.rb +11 -0
  56. data/lib/momento/response/sorted_set/sorted_set_fetch_response.rb +107 -0
  57. data/lib/momento/response/sorted_set/sorted_set_put_element_response.rb +44 -0
  58. data/lib/momento/response/sorted_set/sorted_set_put_elements_response.rb +44 -0
  59. data/lib/momento/version.rb +1 -1
  60. data/lib/momento.rb +6 -1
  61. data/momento.gemspec +5 -3
  62. data/release-please-config.json +1 -1
  63. data/sig/momento/auth/credential_provider.rbs +11 -0
  64. data/sig/momento/cache_client.rbs +11 -0
  65. data/sig/momento/collection_ttl.rbs +22 -0
  66. data/sig/momento/config/configuration.rbs +13 -0
  67. data/sig/momento/config/configurations.rbs +9 -0
  68. data/sig/momento/config/transport/grpc_configuration.rbs +9 -0
  69. data/sig/momento/config/transport/transport_strategy.rbs +7 -0
  70. data/sig/momento/list_caches_response.rbs +7 -0
  71. data/sig/momento/sorted_set_fetch_response.rbs +13 -0
  72. data/sig/momento/sorted_set_put_element_response.rbs +5 -0
  73. data/sig/momento/sorted_set_put_elements_response.rbs +5 -0
  74. metadata +101 -40
  75. data/lib/momento/cacheclient_pb.rb +0 -334
  76. data/lib/momento/cacheclient_services_pb.rb +0 -44
  77. data/lib/momento/controlclient_pb.rb +0 -73
  78. data/lib/momento/controlclient_services_pb.rb +0 -31
  79. data/lib/momento/create_cache_response.rb +0 -37
  80. data/lib/momento/create_cache_response_builder.rb +0 -27
  81. data/lib/momento/delete_cache_response.rb +0 -24
  82. data/lib/momento/delete_response.rb +0 -24
  83. data/lib/momento/get_response_builder.rb +0 -37
  84. data/lib/momento/list_caches_response.rb +0 -77
  85. data/lib/momento/list_caches_response_builder.rb +0 -25
  86. data/lib/momento/set_response.rb +0 -39
  87. data/lib/momento/set_response_builder.rb +0 -25
  88. data/lib/momento/simple_cache_client.rb +0 -336
  89. /data/lib/momento/{response_builder.rb → response/response_builder.rb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ae73ad26d383968c4b0335be41cc9aa1b95078cdbff65b012d54f0309573df3
4
- data.tar.gz: c7717a54a117809b0c0c2cc1fbb2576a1f8046c3577627922055ec89093f38de
3
+ metadata.gz: 8c0a2e256e81604bf29029b9b7e280ad7447a988b030e2b0e4597f1203ab1716
4
+ data.tar.gz: fcec32b5f2994ec2cd4c36a55b6e832d795347c9e4b7ce953b9ab364abbbc6d1
5
5
  SHA512:
6
- metadata.gz: 4723e7ebb12ae06ffd1a0c7fe75c5c5eb516bec1e9474c8283b1f4412d319a9c2e402262b4141c6bd90840f74856915182f85ae082c7b1615d85eba397aec4cf
7
- data.tar.gz: 5dffb98bf9c697786ef1bd5bb2c92bd406738c1c4564cdf5e09a76f760254abd4409eadd8fc0862870b1e1a8f71af6d483315f010a1e432539d1842396a86daf
6
+ metadata.gz: 4e41395f678e2b7cd093b26e0770d76883c4066479ab1beebb85ce6da66c78f0706965b6779d11a15838aa796f1bb73ba8d110b7527ba7ef6012ff6692f9568a
7
+ data.tar.gz: 907ecfb588f18ea17b34ac4d4e9539b451614f2ac0b14bed7500d2671f5cdf016981413d69473ac3cc09d173d2c46c1a924adcbcf21c92adb507629328880df0
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.2.0"
2
+ ".": "0.5.0"
3
3
  }
data/.rubocop.yml CHANGED
@@ -8,7 +8,7 @@ AllCops:
8
8
  TargetRubyVersion: 2.7
9
9
  Exclude:
10
10
  # Generated protobuf files
11
- - 'lib/**/*_pb.rb'
11
+ - 'lib/momento/generated/**/*'
12
12
  - 'vendor/**/*'
13
13
 
14
14
  Layout/ArgumentAlignment:
@@ -71,3 +71,16 @@ Style/WordArray:
71
71
 
72
72
  Layout/LineLength:
73
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
- ruby-3.1.2
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,110 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.0](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.9...momento/v0.5.0) (2024-06-18)
4
+
5
+
6
+ ### Features
7
+
8
+ * add InRegion pre-built config ([#180](https://github.com/momentohq/client-sdk-ruby/issues/180)) ([6dd2ef4](https://github.com/momentohq/client-sdk-ruby/commit/6dd2ef47443dbbd0cae28e1d4451c74352310aa3))
9
+ * add runtime version header, only send agent headers on first request ([#177](https://github.com/momentohq/client-sdk-ruby/issues/177)) ([2292a35](https://github.com/momentohq/client-sdk-ruby/commit/2292a3575c551a2a36c9c3f1a31f0c6870e1c4d1))
10
+ * add support for multiple grpc channels, fix configuration modifiers ([#176](https://github.com/momentohq/client-sdk-ruby/issues/176)) ([5753247](https://github.com/momentohq/client-sdk-ruby/commit/57532472d418db54c6eadd046ea6cbf0a53e4e96))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * add Gemfile.lock to .gitignore ([45e0b6c](https://github.com/momentohq/client-sdk-ruby/commit/45e0b6cdfb19a337f6cb6c17afe2f21fd86b1eb5))
16
+ * improve error handling for env var cred provider, other fixes ([#173](https://github.com/momentohq/client-sdk-ruby/issues/173)) ([c0b691b](https://github.com/momentohq/client-sdk-ruby/commit/c0b691b8c925d99b6a95a9cecee160b777b9dfab))
17
+
18
+ ## [0.4.9](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.8...momento/v0.4.9) (2024-04-30)
19
+
20
+ ### Bug Fixes
21
+
22
+ * 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))
23
+
24
+ ## [0.4.8](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.7...momento/v0.4.8) (2024-04-30)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * 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))
30
+
31
+ ## [0.4.7](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.6...momento/v0.4.7) (2024-04-30)
32
+
33
+
34
+ ### Bug Fixes
35
+
36
+ * update the grpc dependency ([#164](https://github.com/momentohq/client-sdk-ruby/issues/164)) ([00c0ee5](https://github.com/momentohq/client-sdk-ruby/commit/00c0ee578c63b2003b6de23506715447d762997a))
37
+
38
+ ## [0.4.6](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.5...momento/v0.4.6) (2024-04-30)
39
+
40
+
41
+ ### Bug Fixes
42
+
43
+ * 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))
44
+
45
+ ## [0.4.5](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.4...momento/v0.4.5) (2024-04-30)
46
+
47
+
48
+ ### Bug Fixes
49
+
50
+ * 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))
51
+
52
+ ## [0.4.4](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.3...momento/v0.4.4) (2024-04-30)
53
+
54
+
55
+ ### Bug Fixes
56
+
57
+ * 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))
58
+
59
+ ## [0.4.3](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.2...momento/v0.4.3) (2024-04-30)
60
+
61
+
62
+ ### Bug Fixes
63
+
64
+ * verbose rubygems publishing ([#156](https://github.com/momentohq/client-sdk-ruby/issues/156)) ([0f6ec1f](https://github.com/momentohq/client-sdk-ruby/commit/0f6ec1fc958bb9473b4f508f2cb2d1e35beaf90c))
65
+
66
+ ## [0.4.2](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.1...momento/v0.4.2) (2024-04-30)
67
+
68
+
69
+ ### Bug Fixes
70
+
71
+ * 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))
72
+
73
+ ## [0.4.1](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.4.0...momento/v0.4.1) (2024-04-29)
74
+
75
+
76
+ ### Bug Fixes
77
+
78
+ * 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))
79
+
80
+ ## [0.4.0](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.3.0...momento/v0.4.0) (2024-04-29)
81
+
82
+
83
+ ### Features
84
+
85
+ * add a CredentialProvider ([#134](https://github.com/momentohq/client-sdk-ruby/issues/134)) ([c74f34a](https://github.com/momentohq/client-sdk-ruby/commit/c74f34a102d24b6f143376ac4c643139b2559394))
86
+ * 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))
87
+ * add cache config objects as CacheClient argument ([f8c1c86](https://github.com/momentohq/client-sdk-ruby/commit/f8c1c860fa05c83a766b0063835013b32cc35382))
88
+ * 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))
89
+ * 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))
90
+ * rename SimpleCacheClient to CacheClient ([37e2183](https://github.com/momentohq/client-sdk-ruby/commit/37e2183390e3184ad6ce4429df15fdd4b8b15a74))
91
+ * rename SimpleCacheClient to CacheClient ([#141](https://github.com/momentohq/client-sdk-ruby/issues/141)) ([f1e6d86](https://github.com/momentohq/client-sdk-ruby/commit/f1e6d86ea9665bb66164265a7baa85f729d798a8))
92
+ * 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))
93
+
94
+
95
+ ### Bug Fixes
96
+
97
+ * change the ruby versions in the test action to strings ([4700338](https://github.com/momentohq/client-sdk-ruby/commit/47003387cbab0739361eedcdad9662f0a0753757))
98
+ * 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))
99
+ * 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))
100
+
101
+ ## [0.3.0](https://github.com/momentohq/client-sdk-ruby/compare/momento-v0.2.0...momento/v0.3.0) (2023-11-09)
102
+
103
+
104
+ ### Features
105
+
106
+ * add support for v1 tokens ([0a98c34](https://github.com/momentohq/client-sdk-ruby/commit/0a98c3404972966a7c4c2017908f2c204532712d))
107
+
3
108
  ## [0.2.0](https://github.com/momentohq/client-sdk-ruby/compare/momento-v0.1.0...momento/v0.2.0) (2022-12-07)
4
109
 
5
110
  ### Breaking Changes
data/CONTRIBUTING.md CHANGED
@@ -40,13 +40,12 @@ You can run code from the repository's `lib/` directory by adding `-Ilib` to you
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 unit tests
43
+ ## Running tests
44
44
 
45
- Run `rspec`. These tests will make no network calls and do not require a Momento account.
46
-
47
- ## Running integration tests
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
@@ -2,10 +2,5 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- # Specify your gem's dependencies in momento-client.gemspec
5
+ # Specify your gem's dependencies in momento.gemspec
6
6
  gemspec
7
-
8
- gem "pry-byebug"
9
- gem "rake", "~> 13.0"
10
- gem "rspec", "~> 3.0"
11
- gem "rubocop", "~> 1.38"
data/Gemfile.lock CHANGED
@@ -1,9 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- momento (0.2.0)
5
- grpc (~> 1)
6
- jwt (~> 2)
4
+ momento (0.5.0)
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.21.10-x86_64-darwin)
27
- google-protobuf (3.21.10-x86_64-linux)
28
- googleapis-common-protos-types (1.4.0)
29
- google-protobuf (~> 3.14)
30
- grpc (1.50.0-x86_64-darwin)
31
- google-protobuf (~> 3.21)
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.50.0-x86_64-linux)
34
- google-protobuf (~> 3.21)
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)
@@ -51,20 +54,21 @@ GEM
51
54
  rainbow (3.1.1)
52
55
  rake (13.0.6)
53
56
  regexp_parser (2.6.0)
54
- rexml (3.2.5)
55
- rspec (3.11.0)
56
- rspec-core (~> 3.11.0)
57
- rspec-expectations (~> 3.11.0)
58
- rspec-mocks (~> 3.11.0)
59
- rspec-core (3.11.0)
60
- rspec-support (~> 3.11.0)
61
- rspec-expectations (3.11.0)
57
+ rexml (3.2.8)
58
+ strscan (>= 3.0.9)
59
+ rspec (3.12.0)
60
+ rspec-core (~> 3.12.0)
61
+ rspec-expectations (~> 3.12.0)
62
+ rspec-mocks (~> 3.12.0)
63
+ rspec-core (3.12.0)
64
+ rspec-support (~> 3.12.0)
65
+ rspec-expectations (3.12.0)
62
66
  diff-lcs (>= 1.2.0, < 2.0)
63
- rspec-support (~> 3.11.0)
64
- rspec-mocks (3.11.1)
67
+ rspec-support (~> 3.12.0)
68
+ rspec-mocks (3.12.0)
65
69
  diff-lcs (>= 1.2.0, < 2.0)
66
- rspec-support (~> 3.11.0)
67
- rspec-support (3.11.0)
70
+ rspec-support (~> 3.12.0)
71
+ rspec-support (3.12.0)
68
72
  rubocop (1.38.0)
69
73
  json (~> 2.3)
70
74
  parallel (~> 1.10)
@@ -91,14 +95,15 @@ GEM
91
95
  simplecov_json_formatter (~> 0.1)
92
96
  simplecov-html (0.12.3)
93
97
  simplecov_json_formatter (0.1.4)
98
+ strscan (3.1.0)
94
99
  tzinfo (2.0.5)
95
100
  concurrent-ruby (~> 1.0)
96
101
  unicode-display_width (2.3.0)
97
- webrick (1.7.0)
98
- yard (0.9.28)
99
- webrick (~> 1.7.0)
102
+ yard (0.9.36)
100
103
 
101
104
  PLATFORMS
105
+ arm64-darwin-22
106
+ arm64-darwin-23
102
107
  x86_64-darwin-20
103
108
  x86_64-darwin-21
104
109
  x86_64-linux
@@ -107,10 +112,11 @@ DEPENDENCIES
107
112
  bundler (~> 2.3)
108
113
  factory_bot (~> 6.2.1)
109
114
  faker (~> 3.0)
115
+ jwt (~> 2)
110
116
  momento!
111
- pry-byebug
117
+ pry-byebug (~> 3)
112
118
  rake (~> 13.0)
113
- rspec (~> 3.0)
119
+ rspec (~> 3.12)
114
120
  rubocop (~> 1.38)
115
121
  rubocop-performance (~> 1.15)
116
122
  rubocop-rake (~> 0.6.0)
data/README.md CHANGED
@@ -1,40 +1,36 @@
1
1
  <head>
2
- <meta name="Momento Ruby Client Library Documentation" content="Ruby client software development kit for Momento Serverless Cache">
2
+ <meta name="Momento Ruby Client Library Documentation" content="Ruby client software development kit for Momento Cache">
3
3
  </head>
4
- <img src="https://docs.momentohq.com/img/logo.svg" alt="logo" width="400"/>
4
+ <img src="https://docs.momentohq.com/img/momento-logo-forest.svg" alt="logo" width="400"/>
5
5
 
6
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-alpha.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-stable.svg)](https://github.com/momentohq/standards-and-practices/blob/main/docs/momento-on-github.md)
8
8
 
9
9
  # Momento Ruby Client Library
10
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.
11
13
 
12
- :warning: Alpha SDK :warning:
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).
13
15
 
14
- This is an official Momento SDK, but the API is in an alpha stage and may be subject to backward-incompatible
15
- changes. For more info, click on the alpha badge above.
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)
16
21
 
22
+ # Momento Ruby SDK
17
23
 
18
- Ruby client SDK for Momento Serverless Cache: a fast, simple, pay-as-you-go caching solution without
19
- any of the operational overhead required by traditional caching solutions!
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).
20
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)
21
30
 
31
+ ## Packages
22
32
 
23
- ## Getting Started :running:
24
-
25
- ### Requirements
26
-
27
- - A Momento Auth Token is required, you can generate one using
28
- the [Momento CLI](https://github.com/momentohq/momento-cli).
29
- - Ruby 2.7 or newer.
30
-
31
- An IDE with good Ruby support, such as [RubyMine](https://www.jetbrains.com/ruby/), is recommended.
32
-
33
- ### Examples
34
-
35
- You can find this example code and more in [the examples directory](https://github.com/momentohq/client-sdk-ruby/tree/main/examples) of this repository.
36
-
37
- ### Installation
33
+ The Momento Ruby SDK is available on [RubyGems](https://rubygems.org/gems/momento)
38
34
 
39
35
  Install the gem and add to an application's Gemfile by executing:
40
36
 
@@ -48,32 +44,47 @@ If bundler is not being used to manage dependencies, install the gem by executin
48
44
  gem install momento
49
45
  ```
50
46
 
51
- #### Note: M1 or M2 Macs
47
+ You will need Ruby 2.7 or newer.
48
+
49
+ An IDE with good Ruby support, such as [RubyMine](https://www.jetbrains.com/ruby/), is recommended.
52
50
 
53
- 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).
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).
54
52
 
55
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`.
56
54
 
57
- ### Usage
55
+ ## Usage
56
+
57
+ You can find this example code and more in [the examples directory](./examples) of this repository.
58
58
 
59
59
  ```ruby
60
60
  # An example of the basic functionality of
61
- # Momento::SimpleCacheClient.
61
+ # Momento::CacheClient.
62
62
 
63
63
  require 'momento'
64
64
 
65
- # Get your Momento token from an environment variable.
66
- TOKEN = ENV.fetch('MOMENTO_AUTH_TOKEN')
67
-
68
65
  # Cached items will be deleted after 12.5 seconds.
69
66
  TTL_SECONDS = 12.5
70
67
 
71
68
  # The name of the cache to create *and delete*
72
- CACHE_NAME = ENV.fetch('MOMENTO_CACHE_NAME')
69
+ CACHE_NAME = ENV.fetch('MOMENTO_CACHE_NAME', 'ruby-examples')
70
+
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')
73
+
74
+ # This is a reasonable configuration for dev work on a laptop.
75
+ configuration = Momento::Cache::Configurations::Laptop.latest
76
+ # This configuration might be better for a production where you want more aggressive timeouts
77
+ # configuration = Momento::Cache::Configuration::InRegion.latest
78
+ # To set a custom timeout, you can use the with_timeout method.
79
+ # configuration = configuration.with_timeout(10_000)
80
+ # To increase the number of TCP connections for a client where you expect a high volume of traffic,
81
+ # you can use the with_num_connections method.
82
+ # configuration = configuration.with_num_connections(4)
73
83
 
74
84
  # Instantiate a Momento client.
75
- client = Momento::SimpleCacheClient.new(
76
- auth_token: TOKEN,
85
+ client = Momento::CacheClient.new(
86
+ configuration: configuration,
87
+ credential_provider: credential_provider,
77
88
  default_ttl: TTL_SECONDS
78
89
  )
79
90
 
@@ -88,7 +99,12 @@ elsif response.error?
88
99
  end
89
100
 
90
101
  # List our caches.
91
- puts "Caches: #{client.caches.to_a.join(", ")}"
102
+ response = client.list_caches
103
+ if response.success?
104
+ puts "Caches: #{response.cache_names&.join(", ")}"
105
+ elsif response.error?
106
+ raise "Couldn't list the caches: #{response.error}"
107
+ end
92
108
 
93
109
  # Put an item in the cache.
94
110
  response = client.set(CACHE_NAME, "key", "You cached something!")
@@ -126,12 +142,20 @@ end
126
142
 
127
143
  ```
128
144
 
129
- ### Error Handling
145
+ ## Getting Started and Documentation
146
+
147
+ 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!
130
148
 
131
- [Momento::SimpleCacheClient](https://github.com/momentohq/client-sdk-ruby/blob/main/lib/momento/simple_cache_client.rb) follows the philosophy that when working with a service,
149
+ ## Examples
150
+
151
+ Check out full working code in the [example](./example/) directory of this repository!
152
+
153
+ ## Error Handling
154
+
155
+ [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,
132
156
  [exceptions are bugs](https://www.gomomento.com/blog/exceptions-are-bugs). Minor outages are a fact of life; they are normal rather than exceptional.
133
157
 
134
- When there is a problem, Momento::SimpleCacheClient 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.
158
+ 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.
135
159
 
136
160
  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.
137
161
 
@@ -155,21 +179,17 @@ elsif response.error?
155
179
  end
156
180
  ```
157
181
 
158
- Momento::SimpleCacheClient *will* raise exceptions for programmer mistakes such as passing the wrong type, typically an ArgumentError or TypeError. The exceptions are documented for each method.
182
+ 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.
159
183
 
160
184
  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.
161
185
 
162
- ### Tuning
163
-
164
- Coming soon.
165
-
166
186
  ## Issues
167
187
 
168
188
  Please report any bugs, issues, requests, and feedback via this repo's [issue tracker](https://github.com/momentohq/client-sdk-ruby/issues).
169
189
 
170
- ## Contributing
190
+ ## Developing
171
191
 
172
- See our [instructions for CONTRIBUTING](https://github.com/momentohq/client-sdk-ruby/blob/main/CONTRIBUTING.md).
192
+ If you are interested in contributing to the SDK, please see the [CONTRIBUTING](./CONTRIBUTING.md) docs.
173
193
 
174
194
  ----------------------------------------------------------------------------------------
175
195
  For more info, visit our website at [https://gomomento.com](https://gomomento.com)!
data/README.template.md CHANGED
@@ -1,20 +1,17 @@
1
1
  {{ ossHeader }}
2
2
 
3
- ## Getting Started :running:
3
+ # Momento Ruby SDK
4
4
 
5
- ### Requirements
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
6
 
7
- - A Momento Auth Token is required, you can generate one using
8
- the [Momento CLI](https://github.com/momentohq/momento-cli).
9
- - Ruby 2.7 or newer.
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)
10
11
 
11
- An IDE with good Ruby support, such as [RubyMine](https://www.jetbrains.com/ruby/), is recommended.
12
-
13
- ### Examples
14
-
15
- You can find this example code and more in [the examples directory](https://github.com/momentohq/client-sdk-ruby/tree/main/examples) of this repository.
12
+ ## Packages
16
13
 
17
- ### Installation
14
+ The Momento Ruby SDK is available on [RubyGems](https://rubygems.org/gems/momento)
18
15
 
19
16
  Install the gem and add to an application's Gemfile by executing:
20
17
 
@@ -28,24 +25,36 @@ If bundler is not being used to manage dependencies, install the gem by executin
28
25
  gem install momento
29
26
  ```
30
27
 
31
- #### Note: M1 or M2 Macs
28
+ You will need Ruby 2.7 or newer.
32
29
 
33
- 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).
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).
34
33
 
35
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`.
36
35
 
37
- ### Usage
36
+ ## Usage
37
+
38
+ You can find this example code and more in [the examples directory](./examples) of this repository.
38
39
 
39
40
  ```ruby
40
- {{ usageExampleCode }}
41
+ {% include "./examples/example.rb" %}
41
42
  ```
42
43
 
43
- ### Error Handling
44
+ ## Getting Started and Documentation
44
45
 
45
- [Momento::SimpleCacheClient](https://github.com/momentohq/client-sdk-ruby/blob/main/lib/momento/simple_cache_client.rb) follows the philosophy that when working with a service,
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,
46
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.
47
56
 
48
- When there is a problem, Momento::SimpleCacheClient 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.
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.
49
58
 
50
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.
51
60
 
@@ -69,20 +78,16 @@ elsif response.error?
69
78
  end
70
79
  ```
71
80
 
72
- Momento::SimpleCacheClient *will* raise exceptions for programmer mistakes such as passing the wrong type, typically an ArgumentError or TypeError. The exceptions are documented for each method.
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.
73
82
 
74
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.
75
84
 
76
- ### Tuning
77
-
78
- Coming soon.
79
-
80
85
  ## Issues
81
86
 
82
87
  Please report any bugs, issues, requests, and feedback via this repo's [issue tracker](https://github.com/momentohq/client-sdk-ruby/issues).
83
88
 
84
- ## Contributing
89
+ ## Developing
85
90
 
86
- See our [instructions for CONTRIBUTING](https://github.com/momentohq/client-sdk-ruby/blob/main/CONTRIBUTING.md).
91
+ If you are interested in contributing to the SDK, please see the [CONTRIBUTING](./CONTRIBUTING.md) docs.
87
92
 
88
93
  {{ ossFooter }}
data/examples/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  test_copy.jpg
2
+ Gemfile.lock
data/examples/Gemfile CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem 'momento', '~> 0.1.0'
5
+ gem 'momento', '~> 0.4.9'
data/examples/README.md CHANGED
@@ -17,17 +17,16 @@ bundle
17
17
  Then, set the required environment variables:
18
18
 
19
19
  ```bash
20
- export MOMENTO_AUTH_TOKEN=<YOUR_AUTH_TOKEN>
21
- export CACHE_NAME=<YOUR_CACHE_NAME>
20
+ export MOMENTO_API_KEY=<YOUR_API_KEY>
22
21
  ```
23
22
 
24
23
  And now you can run the example programs.
25
24
 
26
- * example.rb - shows off all the basic functionality
27
- * compact.rb - the same, written in a compact style
28
- * file.rb - demonstrates how to cache a file
25
+ * `ruby ./example.rb` - shows off all the basic functionality
26
+ * `ruby ./compact.rb` - the same, written in a compact style
27
+ * `ruby ./file.rb` - demonstrates how to cache a file
29
28
 
30
- If you wish to use the version of momento in this repository, include the lib directory when you run the examples.
29
+ If you wish to use the version of Momento in this repository, include the lib directory when you run the examples.
31
30
 
32
31
  ```sh
33
32
  ruby -I../lib example.rb