momento 0.2.0 → 0.4.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) 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 +91 -0
  6. data/CONTRIBUTING.md +5 -6
  7. data/Gemfile +1 -6
  8. data/Gemfile.lock +30 -24
  9. data/README.md +53 -43
  10. data/README.template.md +30 -25
  11. data/examples/Gemfile +1 -1
  12. data/examples/README.md +3 -3
  13. data/examples/compact.rb +12 -8
  14. data/examples/example.rb +13 -7
  15. data/examples/file.rb +6 -5
  16. data/lib/README-generating-pb.txt +1 -1
  17. data/lib/momento/auth/credential_provider.rb +78 -0
  18. data/lib/momento/cache_client.rb +457 -0
  19. data/lib/momento/collection_ttl.rb +79 -0
  20. data/lib/momento/config/configuration.rb +16 -0
  21. data/lib/momento/config/configurations.rb +17 -0
  22. data/lib/momento/config/transport/grpc_configuration.rb +25 -0
  23. data/lib/momento/config/transport/static_transport_strategy.rb +12 -0
  24. data/lib/momento/config/transport/transport_strategy.rb +16 -0
  25. data/lib/momento/error/types.rb +15 -0
  26. data/lib/momento/generated/README.md +16 -0
  27. data/lib/momento/generated/auth_pb.rb +52 -0
  28. data/lib/momento/generated/auth_services_pb.rb +27 -0
  29. data/lib/momento/generated/cacheclient_pb.rb +203 -0
  30. data/lib/momento/generated/cacheclient_services_pb.rb +90 -0
  31. data/lib/momento/generated/cacheping_pb.rb +38 -0
  32. data/lib/momento/generated/cacheping_services_pb.rb +23 -0
  33. data/lib/momento/generated/cachepubsub_pb.rb +48 -0
  34. data/lib/momento/generated/cachepubsub_services_pb.rb +56 -0
  35. data/lib/momento/generated/common_pb.rb +44 -0
  36. data/lib/momento/generated/controlclient_pb.rb +72 -0
  37. data/lib/momento/generated/controlclient_services_pb.rb +35 -0
  38. data/lib/momento/generated/extensions_pb.rb +35 -0
  39. data/lib/momento/generated/generate_protos.sh +47 -0
  40. data/lib/momento/generated/leaderboard_pb.rb +56 -0
  41. data/lib/momento/generated/leaderboard_services_pb.rb +57 -0
  42. data/lib/momento/generated/permissionmessages_pb.rb +48 -0
  43. data/lib/momento/generated/token_pb.rb +43 -0
  44. data/lib/momento/generated/token_services_pb.rb +23 -0
  45. data/lib/momento/generated/webhook_pb.rb +49 -0
  46. data/lib/momento/generated/webhook_services_pb.rb +32 -0
  47. data/lib/momento/response/control/create_cache_response.rb +61 -0
  48. data/lib/momento/{delete_cache_response_builder.rb → response/control/delete_cache_response.rb} +24 -3
  49. data/lib/momento/response/control/list_caches_response.rb +80 -0
  50. data/lib/momento/{delete_response_builder.rb → response/delete_response.rb} +24 -2
  51. data/lib/momento/{get_response.rb → response/get_response.rb} +39 -9
  52. data/lib/momento/{response.rb → response/response.rb} +11 -14
  53. data/lib/momento/response/set_response.rb +59 -0
  54. data/lib/momento/response/sort_order.rb +11 -0
  55. data/lib/momento/response/sorted_set/sorted_set_fetch_response.rb +107 -0
  56. data/lib/momento/response/sorted_set/sorted_set_put_element_response.rb +44 -0
  57. data/lib/momento/response/sorted_set/sorted_set_put_elements_response.rb +44 -0
  58. data/lib/momento/version.rb +1 -1
  59. data/lib/momento.rb +6 -1
  60. data/momento.gemspec +5 -3
  61. data/release-please-config.json +1 -1
  62. data/sig/momento/auth/credential_provider.rbs +11 -0
  63. data/sig/momento/cache_client.rbs +12 -0
  64. data/sig/momento/collection_ttl.rbs +22 -0
  65. data/sig/momento/config/configuration.rbs +9 -0
  66. data/sig/momento/config/configurations.rbs +9 -0
  67. data/sig/momento/config/transport/grpc_configuration.rbs +7 -0
  68. data/sig/momento/config/transport/transport_strategy.rbs +7 -0
  69. data/sig/momento/list_caches_response.rbs +7 -0
  70. data/sig/momento/sorted_set_fetch_response.rbs +13 -0
  71. data/sig/momento/sorted_set_put_element_response.rbs +5 -0
  72. data/sig/momento/sorted_set_put_elements_response.rbs +5 -0
  73. metadata +101 -40
  74. data/lib/momento/cacheclient_pb.rb +0 -334
  75. data/lib/momento/cacheclient_services_pb.rb +0 -44
  76. data/lib/momento/controlclient_pb.rb +0 -73
  77. data/lib/momento/controlclient_services_pb.rb +0 -31
  78. data/lib/momento/create_cache_response.rb +0 -37
  79. data/lib/momento/create_cache_response_builder.rb +0 -27
  80. data/lib/momento/delete_cache_response.rb +0 -24
  81. data/lib/momento/delete_response.rb +0 -24
  82. data/lib/momento/get_response_builder.rb +0 -37
  83. data/lib/momento/list_caches_response.rb +0 -77
  84. data/lib/momento/list_caches_response_builder.rb +0 -25
  85. data/lib/momento/set_response.rb +0 -39
  86. data/lib/momento/set_response_builder.rb +0 -25
  87. data/lib/momento/simple_cache_client.rb +0 -336
  88. /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: 616d2ff01199640c05162ca979fb1ab260c1522c8b86a46d34c68ade3f7c430b
4
+ data.tar.gz: 54e756e639fd2c9fe5b5e004ccb0d1e6d9b6a9368ead7a8b4d518e908100b75a
5
5
  SHA512:
6
- metadata.gz: 4723e7ebb12ae06ffd1a0c7fe75c5c5eb516bec1e9474c8283b1f4412d319a9c2e402262b4141c6bd90840f74856915182f85ae082c7b1615d85eba397aec4cf
7
- data.tar.gz: 5dffb98bf9c697786ef1bd5bb2c92bd406738c1c4564cdf5e09a76f760254abd4409eadd8fc0862870b1e1a8f71af6d483315f010a1e432539d1842396a86daf
6
+ metadata.gz: 48f6a80d7798f86b4bcd0d90dc7cb2ba0bec542554e443c2453756cb31b61fbef3f2ff38ad0933b1a71207d45a7782882829247630616605f8dd6d3c5ad68a6d
7
+ data.tar.gz: ab18d86ce358a2b63d67e953460dddb039c29d01412fddf730a4b55d3210910a1e43c759c78b375cf305c95e6d250f44259d0b6df7f34c1fead22ebbb4e727c7
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.2.0"
2
+ ".": "0.4.9"
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,96 @@
1
1
  # Changelog
2
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
+
3
94
  ## [0.2.0](https://github.com/momentohq/client-sdk-ruby/compare/momento-v0.1.0...momento/v0.2.0) (2022-12-07)
4
95
 
5
96
  ### 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.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.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)
@@ -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.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)
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.11.0)
64
- rspec-mocks (3.11.1)
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.11.0)
67
- rspec-support (3.11.0)
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)
@@ -99,6 +102,8 @@ GEM
99
102
  webrick (~> 1.7.0)
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-beta.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,37 @@ 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
69
  CACHE_NAME = ENV.fetch('MOMENTO_CACHE_NAME')
73
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
74
  # Instantiate a Momento client.
75
- client = Momento::SimpleCacheClient.new(
76
- auth_token: TOKEN,
75
+ client = Momento::CacheClient.new(
76
+ configuration: Momento::Cache::Configurations::Laptop.latest,
77
+ credential_provider: credential_provider,
77
78
  default_ttl: TTL_SECONDS
78
79
  )
79
80
 
@@ -88,7 +89,12 @@ elsif response.error?
88
89
  end
89
90
 
90
91
  # List our caches.
91
- puts "Caches: #{client.caches.to_a.join(", ")}"
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}"
97
+ end
92
98
 
93
99
  # Put an item in the cache.
94
100
  response = client.set(CACHE_NAME, "key", "You cached something!")
@@ -126,12 +132,20 @@ end
126
132
 
127
133
  ```
128
134
 
129
- ### Error Handling
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!
130
138
 
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,
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,
132
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.
133
147
 
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.
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.
135
149
 
136
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.
137
151
 
@@ -155,21 +169,17 @@ elsif response.error?
155
169
  end
156
170
  ```
157
171
 
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.
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.
159
173
 
160
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.
161
175
 
162
- ### Tuning
163
-
164
- Coming soon.
165
-
166
176
  ## Issues
167
177
 
168
178
  Please report any bugs, issues, requests, and feedback via this repo's [issue tracker](https://github.com/momentohq/client-sdk-ruby/issues).
169
179
 
170
- ## Contributing
180
+ ## Developing
171
181
 
172
- See our [instructions for CONTRIBUTING](https://github.com/momentohq/client-sdk-ruby/blob/main/CONTRIBUTING.md).
182
+ If you are interested in contributing to the SDK, please see the [CONTRIBUTING](./CONTRIBUTING.md) docs.
173
183
 
174
184
  ----------------------------------------------------------------------------------------
175
185
  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/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.2.0'
data/examples/README.md CHANGED
@@ -17,8 +17,8 @@ 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>
21
+ export MOMENTO_CACHE_NAME=<YOUR_CACHE_NAME>
22
22
  ```
23
23
 
24
24
  And now you can run the example programs.
@@ -27,7 +27,7 @@ And now you can run the example programs.
27
27
  * compact.rb - the same, written in a compact style
28
28
  * file.rb - demonstrates how to cache a file
29
29
 
30
- If you wish to use the version of momento in this repository, include the lib directory when you run the examples.
30
+ If you wish to use the version of Momento in this repository, include the lib directory when you run the examples.
31
31
 
32
32
  ```sh
33
33
  ruby -I../lib example.rb
data/examples/compact.rb CHANGED
@@ -2,18 +2,19 @@
2
2
 
3
3
  require 'momento'
4
4
 
5
- # Get your Momento token from an environment variable.
6
- TOKEN = ENV.fetch('MOMENTO_AUTH_TOKEN')
7
-
8
- # Cached items will be deleted after 12.5 seconds.
9
- TTL_SECONDS = 12.5
5
+ # Cached items will be deleted after 10 seconds.
6
+ TTL_SECONDS = 10
10
7
 
11
8
  # The name of the cache to create *and delete*
12
9
  CACHE_NAME = ENV.fetch('MOMENTO_CACHE_NAME')
13
10
 
11
+ # Create a credential provider that loads a Momento API Key from an environment variable.
12
+ credential_provider = Momento::CredentialProvider.from_env_var('MOMENTO_API_KEY')
13
+
14
14
  # Instantiate a Momento client.
15
- client = Momento::SimpleCacheClient.new(
16
- auth_token: TOKEN,
15
+ client = Momento::CacheClient.new(
16
+ configuration: Momento::Cache::Configurations::Laptop.latest,
17
+ credential_provider: credential_provider,
17
18
  default_ttl: TTL_SECONDS
18
19
  )
19
20
 
@@ -23,7 +24,10 @@ response = client.create_cache(CACHE_NAME)
23
24
  raise response.error if response.error?
24
25
 
25
26
  # List our caches.
26
- puts "Caches: #{client.caches.to_a.join(", ")}"
27
+ response = client.list_caches
28
+ raise response.error if response.error?
29
+
30
+ puts "Caches: #{response.cache_names&.join(", ")}"
27
31
 
28
32
  # Put an item in the cache.
29
33
  response = client.set(CACHE_NAME, "key", "You cached something!")
data/examples/example.rb CHANGED
@@ -1,20 +1,21 @@
1
1
  # An example of the basic functionality of
2
- # Momento::SimpleCacheClient.
2
+ # Momento::CacheClient.
3
3
 
4
4
  require 'momento'
5
5
 
6
- # Get your Momento token from an environment variable.
7
- TOKEN = ENV.fetch('MOMENTO_AUTH_TOKEN')
8
-
9
6
  # Cached items will be deleted after 12.5 seconds.
10
7
  TTL_SECONDS = 12.5
11
8
 
12
9
  # The name of the cache to create *and delete*
13
10
  CACHE_NAME = ENV.fetch('MOMENTO_CACHE_NAME')
14
11
 
12
+ # Create a credential provider that loads a Momento API Key from an environment variable.
13
+ credential_provider = Momento::CredentialProvider.from_env_var('MOMENTO_API_KEY')
14
+
15
15
  # Instantiate a Momento client.
16
- client = Momento::SimpleCacheClient.new(
17
- auth_token: TOKEN,
16
+ client = Momento::CacheClient.new(
17
+ configuration: Momento::Cache::Configurations::Laptop.latest,
18
+ credential_provider: credential_provider,
18
19
  default_ttl: TTL_SECONDS
19
20
  )
20
21
 
@@ -29,7 +30,12 @@ elsif response.error?
29
30
  end
30
31
 
31
32
  # List our caches.
32
- puts "Caches: #{client.caches.to_a.join(", ")}"
33
+ response = client.list_caches
34
+ if response.success?
35
+ puts "Caches: #{response.cache_names&.join(", ")}"
36
+ elsif response.error?
37
+ raise "Couldn't list the caches: #{response.error}"
38
+ end
33
39
 
34
40
  # Put an item in the cache.
35
41
  response = client.set(CACHE_NAME, "key", "You cached something!")