legion-cache 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +19 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +39 -15
- data/CHANGELOG.md +17 -3
- data/CLAUDE.md +140 -0
- data/Gemfile +2 -0
- data/LICENSE +1 -1
- data/README.md +87 -27
- data/legion-cache.gemspec +14 -14
- data/lib/legion/cache/local.rb +115 -0
- data/lib/legion/cache/memcached.rb +19 -6
- data/lib/legion/cache/pool.rb +4 -0
- data/lib/legion/cache/redis.rb +3 -1
- data/lib/legion/cache/settings.rb +32 -11
- data/lib/legion/cache/version.rb +1 -1
- data/lib/legion/cache.rb +81 -12
- metadata +23 -32
- data/.github/workflows/rubocop-analysis.yml +0 -28
- data/.github/workflows/sourcehawk-scan.yml +0 -20
- data/CODE_OF_CONDUCT.md +0 -75
- data/CONTRIBUTING.md +0 -55
- data/INDIVIDUAL_CONTRIBUTOR_LICENSE.md +0 -30
- data/NOTICE.txt +0 -9
- data/SECURITY.md +0 -9
- data/attribution.txt +0 -1
- data/sourcehawk.yml +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e74d63805b57a8da13750d3a281d1ef6b25989454bd7dfa385da9d0ba3087a0b
|
|
4
|
+
data.tar.gz: 2949f0b310c3653516e4dedd0f1def27e8cc9621baf1bace393fcb439c722ace
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9f549b3501d9bdfe38e9a3fb19cb5afba9418be9676dfa6a1a0086f7d1f8dbfe6a9e9a64a19dc8a6f60be4282b91096cabcd404cff7a0938257073fdd224fbec
|
|
7
|
+
data.tar.gz: 7c2a1d4d2adf6357d619961f6bc02d4945a6d23b43807079f4c58ebaaf939b38128965f21934538cfaff64833892acb92f6b9bbe2b5ecacd9c8eb4e978c33698
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
ci:
|
|
9
|
+
uses: LegionIO/.github/.github/workflows/ci.yml@main
|
|
10
|
+
with:
|
|
11
|
+
needs-redis: true
|
|
12
|
+
needs-memcached: true
|
|
13
|
+
|
|
14
|
+
release:
|
|
15
|
+
needs: ci
|
|
16
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
17
|
+
uses: LegionIO/.github/.github/workflows/release.yml@main
|
|
18
|
+
secrets:
|
|
19
|
+
rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,26 +1,50 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 3.4
|
|
3
|
+
NewCops: enable
|
|
4
|
+
SuggestExtensions: false
|
|
5
|
+
|
|
1
6
|
Layout/LineLength:
|
|
2
|
-
Max:
|
|
3
|
-
|
|
4
|
-
|
|
7
|
+
Max: 160
|
|
8
|
+
|
|
9
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
|
10
|
+
EnforcedStyle: space
|
|
11
|
+
|
|
12
|
+
Layout/HashAlignment:
|
|
13
|
+
EnforcedHashRocketStyle: table
|
|
14
|
+
EnforcedColonStyle: table
|
|
15
|
+
|
|
5
16
|
Metrics/MethodLength:
|
|
6
|
-
Max:
|
|
17
|
+
Max: 50
|
|
18
|
+
|
|
7
19
|
Metrics/ClassLength:
|
|
8
20
|
Max: 1500
|
|
21
|
+
|
|
22
|
+
Metrics/ModuleLength:
|
|
23
|
+
Max: 1500
|
|
24
|
+
|
|
9
25
|
Metrics/BlockLength:
|
|
10
|
-
Max:
|
|
26
|
+
Max: 40
|
|
11
27
|
Exclude:
|
|
12
|
-
- 'spec
|
|
28
|
+
- 'spec/**/*'
|
|
29
|
+
|
|
13
30
|
Metrics/AbcSize:
|
|
14
|
-
Max:
|
|
31
|
+
Max: 60
|
|
32
|
+
|
|
33
|
+
Metrics/CyclomaticComplexity:
|
|
34
|
+
Max: 15
|
|
35
|
+
|
|
36
|
+
Metrics/PerceivedComplexity:
|
|
37
|
+
Max: 17
|
|
38
|
+
|
|
15
39
|
Style/Documentation:
|
|
16
40
|
Enabled: false
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
NewCops: enable
|
|
22
|
-
SuggestExtensions: false
|
|
41
|
+
|
|
42
|
+
Style/SymbolArray:
|
|
43
|
+
Enabled: true
|
|
44
|
+
|
|
23
45
|
Style/FrozenStringLiteralComment:
|
|
46
|
+
Enabled: true
|
|
47
|
+
EnforcedStyle: always
|
|
48
|
+
|
|
49
|
+
Naming/FileName:
|
|
24
50
|
Enabled: false
|
|
25
|
-
Gemspec/RequiredRubyVersion:
|
|
26
|
-
Enabled: false
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
4
|
-
|
|
3
|
+
## [1.3.0] - 2026-03-16
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- `Legion::Cache::Local` module for local Redis/Memcached caching
|
|
7
|
+
- `Settings.local` with independent defaults (namespace: `legion_local`, pool_size: 5, timeout: 3)
|
|
8
|
+
- Transparent fallback: shared cache failure at setup redirects all operations to Local
|
|
9
|
+
- `Legion::Cache.local` accessor, `Legion::Cache.using_local?` query
|
|
10
|
+
|
|
11
|
+
## [1.2.1] - 2026-03-16
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- Set dalli `value_max_bytes` to 8MB by default — dalli enforces a 1MB client-side limit that prevented large cache values from being stored even when memcached server allows larger items
|
|
15
|
+
|
|
16
|
+
## [1.2.0]
|
|
17
|
+
|
|
18
|
+
Moving from BitBucket to GitHub. All git history is reset from this point on
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# legion-cache: Caching Layer for LegionIO
|
|
2
|
+
|
|
3
|
+
**Repository Level 3 Documentation**
|
|
4
|
+
- **Parent**: `/Users/miverso2/rubymine/legion/CLAUDE.md`
|
|
5
|
+
|
|
6
|
+
## Purpose
|
|
7
|
+
|
|
8
|
+
Caching wrapper for the LegionIO framework. Provides a consistent interface for Memcached (via `dalli`) and Redis (via `redis` gem) with connection pooling. Driver selection is config-driven.
|
|
9
|
+
|
|
10
|
+
**GitHub**: https://github.com/LegionIO/legion-cache
|
|
11
|
+
**License**: Apache-2.0
|
|
12
|
+
|
|
13
|
+
## Architecture
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
Legion::Cache (singleton module)
|
|
17
|
+
├── .setup(**opts) # Connect to cache backend
|
|
18
|
+
├── .get(key) # Retrieve cached value
|
|
19
|
+
├── .fetch(key, ttl) # Get with block/TTL support (Memcached only; alias for get on Redis)
|
|
20
|
+
├── .set(key, value, ttl) # Store value with optional TTL (positional on Memcached, keyword on Redis)
|
|
21
|
+
├── .delete(key) # Remove a key
|
|
22
|
+
├── .flush # Flush all keys (flush(delay) on Memcached, flushdb on Redis)
|
|
23
|
+
├── .connected? # Connection status
|
|
24
|
+
├── .size # Total pool connections
|
|
25
|
+
├── .available # Idle pool connections
|
|
26
|
+
├── .restart(**opts) # Close and reconnect pool with optional new opts
|
|
27
|
+
├── .shutdown # Close connections, mark disconnected
|
|
28
|
+
├── .local # Accessor for Legion::Cache::Local
|
|
29
|
+
├── .using_local? # Whether fallback to local is active
|
|
30
|
+
│
|
|
31
|
+
├── Memcached # Dalli-based Memcached driver (default)
|
|
32
|
+
│ └── Uses connection_pool for thread safety
|
|
33
|
+
│ └── value_max_bytes defaults to 8MB (overrides dalli's 1MB client-side limit)
|
|
34
|
+
├── Redis # Redis driver
|
|
35
|
+
│ └── Uses connection_pool for thread safety
|
|
36
|
+
│ └── Default pool_size is 20 (Memcached default is 10)
|
|
37
|
+
├── Local # Local cache tier (localhost Redis/Memcached, fallback target)
|
|
38
|
+
│ ├── .setup # Connect to local cache server (auto-detect driver)
|
|
39
|
+
│ ├── .shutdown # Close local connection
|
|
40
|
+
│ ├── .connected? # Whether local cache is active
|
|
41
|
+
│ ├── .get/set/delete/fetch/flush # Cache operations on local tier
|
|
42
|
+
│ ├── .restart(**opts) # Close and reconnect with new opts
|
|
43
|
+
│ └── .reset! # Clear all state (testing)
|
|
44
|
+
├── Pool # Connection pool management (connected?, size, available, close, restart)
|
|
45
|
+
├── Settings # Default cache config + driver auto-detection
|
|
46
|
+
└── Version
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Key Design Patterns
|
|
50
|
+
|
|
51
|
+
- **Driver Selection at Load Time**: `Legion::Settings[:cache][:driver]` determines which module gets `extend`ed into `Legion::Cache` (`'redis'` or `'dalli'`)
|
|
52
|
+
- **Connection Pooling**: Both drivers use `connection_pool` gem for thread-safe access
|
|
53
|
+
- **Unified Interface**: Same `get`/`set`/`delete`/`flush`/`connected?`/`shutdown` methods regardless of backend
|
|
54
|
+
- **TTL Signature Difference**: Memcached `set(key, value, ttl)` uses a positional TTL (default 180s); Redis `set(key, value, ttl: nil)` uses a keyword TTL
|
|
55
|
+
|
|
56
|
+
### Two-Tier Cache Architecture
|
|
57
|
+
|
|
58
|
+
- **Shared** (`Legion::Cache`) — remote Redis/Memcached cluster for cross-node caching
|
|
59
|
+
- **Local** (`Legion::Cache::Local`) — localhost Redis/Memcached for per-machine caching
|
|
60
|
+
- **Fallback**: If shared cluster is unreachable at setup, all operations transparently delegate to Local
|
|
61
|
+
- Both tiers use the same driver modules (`Memcached`/`Redis`) with independent connection pools
|
|
62
|
+
- Local uses `.dup` on the driver module to get isolated `@client`/`@connected` state
|
|
63
|
+
|
|
64
|
+
## Default Settings
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"driver": "dalli",
|
|
69
|
+
"servers": ["127.0.0.1:11211"],
|
|
70
|
+
"connected": false,
|
|
71
|
+
"enabled": true,
|
|
72
|
+
"namespace": "legion",
|
|
73
|
+
"compress": false,
|
|
74
|
+
"failover": true,
|
|
75
|
+
"threadsafe": true,
|
|
76
|
+
"cache_nils": false,
|
|
77
|
+
"pool_size": 10,
|
|
78
|
+
"timeout": 5,
|
|
79
|
+
"expires_in": 0,
|
|
80
|
+
"serializer": "Legion::JSON"
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The `driver` is auto-detected at load time: prefers `dalli`, falls back to `redis` if dalli is unavailable. Both gems are required dependencies so auto-detection is a fallback for unusual environments.
|
|
85
|
+
|
|
86
|
+
### Local Default Settings
|
|
87
|
+
|
|
88
|
+
`Legion::Cache::Settings.local` provides independent defaults for the local tier:
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"driver": "dalli",
|
|
93
|
+
"servers": ["127.0.0.1:11211"],
|
|
94
|
+
"connected": false,
|
|
95
|
+
"enabled": true,
|
|
96
|
+
"namespace": "legion_local",
|
|
97
|
+
"compress": false,
|
|
98
|
+
"failover": false,
|
|
99
|
+
"threadsafe": true,
|
|
100
|
+
"cache_nils": false,
|
|
101
|
+
"pool_size": 5,
|
|
102
|
+
"timeout": 3,
|
|
103
|
+
"expires_in": 0,
|
|
104
|
+
"serializer": "Legion::JSON"
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Memcached value_max_bytes
|
|
109
|
+
|
|
110
|
+
Dalli enforces a 1MB client-side limit by default (`value_max_bytes: 1_048_576`). The Memcached driver overrides this to **8MB** (`8 * 1024 * 1024`) unless explicitly set. This prevents silent rejection of large cached values. The Memcached server must also be started with `-I 8m` to accept values up to 8MB server-side.
|
|
111
|
+
|
|
112
|
+
## Dependencies
|
|
113
|
+
|
|
114
|
+
| Gem | Purpose |
|
|
115
|
+
|-----|---------|
|
|
116
|
+
| `dalli` (>= 3.0) | Memcached client |
|
|
117
|
+
| `redis` (>= 5.0) | Redis client |
|
|
118
|
+
| `connection_pool` (>= 2.4) | Thread-safe connection pooling |
|
|
119
|
+
| `legion-logging` | Logging |
|
|
120
|
+
| `legion-settings` | Configuration |
|
|
121
|
+
|
|
122
|
+
## File Map
|
|
123
|
+
|
|
124
|
+
| Path | Purpose |
|
|
125
|
+
|------|---------|
|
|
126
|
+
| `lib/legion/cache.rb` | Module entry, driver selection, setup/shutdown, fallback wiring |
|
|
127
|
+
| `lib/legion/cache/memcached.rb` | Dalli/Memcached driver implementation |
|
|
128
|
+
| `lib/legion/cache/redis.rb` | Redis driver implementation |
|
|
129
|
+
| `lib/legion/cache/local.rb` | Local cache tier (localhost, fallback target) |
|
|
130
|
+
| `lib/legion/cache/pool.rb` | Connection pool management |
|
|
131
|
+
| `lib/legion/cache/settings.rb` | Default configuration + local defaults |
|
|
132
|
+
| `lib/legion/cache/version.rb` | VERSION constant |
|
|
133
|
+
|
|
134
|
+
## Role in LegionIO
|
|
135
|
+
|
|
136
|
+
Optional caching layer initialized during `Legion::Service` startup. Used by `legion-data` for model caching (Sequel caching plugin) and by extensions for general-purpose caching.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
**Maintained By**: Matthew Iverson (@Esity)
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright 2021
|
|
189
|
+
Copyright 2021 Esity
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
data/README.md
CHANGED
|
@@ -1,59 +1,119 @@
|
|
|
1
|
-
|
|
2
|
-
=====
|
|
1
|
+
# legion-cache
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
Caching wrapper for the [LegionIO](https://github.com/LegionIO/LegionIO) framework. Provides a consistent interface for Memcached (via `dalli`) and Redis (via `redis` gem) with connection pooling. Driver selection is config-driven.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
------------------------------------------------
|
|
5
|
+
**Version**: 1.3.0
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* JRuby 9.2+
|
|
12
|
-
* Ruby 2.4+
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Installation and Usage
|
|
16
|
-
------------------------
|
|
17
|
-
|
|
18
|
-
You can verify your installation using this piece of code:
|
|
7
|
+
## Installation
|
|
19
8
|
|
|
20
9
|
```bash
|
|
21
10
|
gem install legion-cache
|
|
22
11
|
```
|
|
23
12
|
|
|
13
|
+
Or add to your Gemfile:
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
gem 'legion-cache'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
24
21
|
```ruby
|
|
25
22
|
require 'legion/cache'
|
|
26
23
|
|
|
27
24
|
Legion::Cache.setup
|
|
28
25
|
Legion::Cache.connected? # => true
|
|
26
|
+
|
|
27
|
+
# Memcached driver (default) — TTL is a positional argument, default 180s
|
|
28
|
+
Legion::Cache.set('foobar', 'testing', 10)
|
|
29
|
+
Legion::Cache.get('foobar') # => 'testing'
|
|
30
|
+
Legion::Cache.fetch('foobar') # => 'testing' (get with block support)
|
|
31
|
+
Legion::Cache.delete('foobar') # => true
|
|
32
|
+
Legion::Cache.flush # flush all keys
|
|
33
|
+
|
|
34
|
+
# Redis driver — TTL is a keyword argument
|
|
29
35
|
Legion::Cache.set('foobar', 'testing', ttl: 10)
|
|
30
|
-
Legion::Cache.get('foobar')
|
|
31
|
-
|
|
32
|
-
Legion::Cache.
|
|
36
|
+
Legion::Cache.get('foobar') # => 'testing'
|
|
37
|
+
Legion::Cache.delete('foobar') # => true
|
|
38
|
+
Legion::Cache.flush # flushdb
|
|
33
39
|
|
|
40
|
+
Legion::Cache.shutdown
|
|
34
41
|
```
|
|
35
42
|
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
## Two-Tier Cache
|
|
44
|
+
|
|
45
|
+
Legion::Cache supports a two-tier architecture: a shared remote cluster and a local per-machine cache. If the shared cluster is unreachable at setup, all operations transparently fall back to local.
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
# Shared cache connects to remote cluster; Local connects to localhost
|
|
49
|
+
Legion::Cache.setup # starts Local first, then tries shared
|
|
50
|
+
Legion::Cache.using_local? # => true if shared was unreachable
|
|
51
|
+
Legion::Cache.local # => Legion::Cache::Local
|
|
52
|
+
|
|
53
|
+
# Use Local directly if needed
|
|
54
|
+
Legion::Cache::Local.setup
|
|
55
|
+
Legion::Cache::Local.set('key', 'value', 60)
|
|
56
|
+
Legion::Cache::Local.get('key') # => 'value'
|
|
57
|
+
Legion::Cache::Local.shutdown
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Local uses a separate namespace (`legion_local`) and independent connection pool (pool_size: 5, timeout: 3) so it never collides with the shared tier.
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
38
63
|
|
|
39
64
|
```json
|
|
40
65
|
{
|
|
41
66
|
"driver": "dalli",
|
|
42
|
-
"servers": [
|
|
43
|
-
"127.0.0.1:11211"
|
|
44
|
-
],
|
|
67
|
+
"servers": ["127.0.0.1:11211"],
|
|
45
68
|
"connected": false,
|
|
46
69
|
"enabled": true,
|
|
47
70
|
"namespace": "legion",
|
|
48
71
|
"compress": false,
|
|
72
|
+
"failover": true,
|
|
73
|
+
"threadsafe": true,
|
|
49
74
|
"cache_nils": false,
|
|
50
75
|
"pool_size": 10,
|
|
51
|
-
"timeout":
|
|
76
|
+
"timeout": 5,
|
|
52
77
|
"expires_in": 0
|
|
53
78
|
}
|
|
54
79
|
```
|
|
55
80
|
|
|
56
|
-
|
|
57
|
-
|
|
81
|
+
The driver is auto-detected at load time: prefers `dalli` (Memcached) if available, falls back to `redis`. Override with `"driver": "redis"` and update `servers` to point at your Redis instance.
|
|
82
|
+
|
|
83
|
+
### Memcached notes
|
|
84
|
+
|
|
85
|
+
- `value_max_bytes` defaults to **8MB**. Dalli enforces a 1MB client-side limit by default, which silently rejects large values. This default overrides that. Your Memcached server should also be started with `-I 8m` to match.
|
|
86
|
+
- Redis default pool size is 20; Memcached default pool size is 10.
|
|
87
|
+
|
|
88
|
+
### Local Cache Settings
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"driver": "dalli",
|
|
93
|
+
"servers": ["127.0.0.1:11211"],
|
|
94
|
+
"namespace": "legion_local",
|
|
95
|
+
"pool_size": 5,
|
|
96
|
+
"timeout": 3
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Override via `Legion::Settings[:cache_local]`.
|
|
101
|
+
|
|
102
|
+
## Pool API
|
|
103
|
+
|
|
104
|
+
```ruby
|
|
105
|
+
Legion::Cache.connected? # => true/false
|
|
106
|
+
Legion::Cache.size # total pool connections
|
|
107
|
+
Legion::Cache.available # idle pool connections
|
|
108
|
+
Legion::Cache.restart # close and reconnect pool
|
|
109
|
+
Legion::Cache.shutdown # close pool and mark disconnected
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Requirements
|
|
113
|
+
|
|
114
|
+
- Ruby >= 3.4
|
|
115
|
+
- Memcached or Redis server
|
|
116
|
+
|
|
117
|
+
## License
|
|
58
118
|
|
|
59
|
-
|
|
119
|
+
Apache-2.0
|
data/legion-cache.gemspec
CHANGED
|
@@ -6,29 +6,29 @@ Gem::Specification.new do |spec|
|
|
|
6
6
|
spec.name = 'legion-cache'
|
|
7
7
|
spec.version = Legion::Cache::VERSION
|
|
8
8
|
spec.authors = ['Esity']
|
|
9
|
-
spec.email =
|
|
9
|
+
spec.email = ['matthewdiverson@gmail.com']
|
|
10
10
|
|
|
11
11
|
spec.summary = 'Wraps both the redis and dalli gems to make a consistent interface for accessing cached objects'
|
|
12
12
|
spec.description = 'A Wrapper class for the LegionIO framework to interface with both Memcached and Redis for caching purposes'
|
|
13
|
-
spec.homepage = 'https://github.com/
|
|
13
|
+
spec.homepage = 'https://github.com/LegionIO/legion-cache'
|
|
14
14
|
spec.license = 'Apache-2.0'
|
|
15
15
|
spec.require_paths = ['lib']
|
|
16
|
-
spec.required_ruby_version = '>=
|
|
16
|
+
spec.required_ruby_version = '>= 3.4'
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
18
|
-
spec.
|
|
19
|
-
spec.extra_rdoc_files = %w[README.md LICENSE CHANGELOG.md]
|
|
18
|
+
spec.extra_rdoc_files = %w[README.md LICENSE CHANGELOG.md]
|
|
20
19
|
spec.metadata = {
|
|
21
|
-
'bug_tracker_uri'
|
|
22
|
-
'changelog_uri'
|
|
23
|
-
'documentation_uri'
|
|
24
|
-
'homepage_uri'
|
|
25
|
-
'source_code_uri'
|
|
26
|
-
'wiki_uri'
|
|
20
|
+
'bug_tracker_uri' => 'https://github.com/LegionIO/legion-cache/issues',
|
|
21
|
+
'changelog_uri' => 'https://github.com/LegionIO/legion-cache/blob/main/CHANGELOG.md',
|
|
22
|
+
'documentation_uri' => 'https://github.com/LegionIO/legion-cache',
|
|
23
|
+
'homepage_uri' => 'https://github.com/LegionIO/LegionIO',
|
|
24
|
+
'source_code_uri' => 'https://github.com/LegionIO/legion-cache',
|
|
25
|
+
'wiki_uri' => 'https://github.com/LegionIO/legion-cache/wiki',
|
|
26
|
+
'rubygems_mfa_required' => 'true'
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
spec.add_dependency 'connection_pool', '>= 2.
|
|
30
|
-
spec.add_dependency 'dalli', '>=
|
|
29
|
+
spec.add_dependency 'connection_pool', '>= 2.4'
|
|
30
|
+
spec.add_dependency 'dalli', '>= 3.0'
|
|
31
31
|
spec.add_dependency 'legion-logging'
|
|
32
32
|
spec.add_dependency 'legion-settings'
|
|
33
|
-
spec.add_dependency 'redis', '>=
|
|
33
|
+
spec.add_dependency 'redis', '>= 5.0'
|
|
34
34
|
end
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/cache/settings'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Cache
|
|
7
|
+
module Local
|
|
8
|
+
class << self
|
|
9
|
+
def setup(**)
|
|
10
|
+
return if @connected
|
|
11
|
+
|
|
12
|
+
settings = local_settings
|
|
13
|
+
return unless settings[:enabled]
|
|
14
|
+
|
|
15
|
+
driver_name = settings[:driver] || Legion::Cache::Settings.driver
|
|
16
|
+
@driver = build_driver(driver_name)
|
|
17
|
+
@driver.client(**settings, **)
|
|
18
|
+
@connected = true
|
|
19
|
+
Legion::Logging.info "Legion::Cache::Local connected (#{driver_name})" if defined?(Legion::Logging)
|
|
20
|
+
rescue StandardError => e
|
|
21
|
+
Legion::Logging.warn "Legion::Cache::Local setup failed: #{e.message}" if defined?(Legion::Logging)
|
|
22
|
+
@connected = false
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def shutdown
|
|
26
|
+
return unless @connected
|
|
27
|
+
|
|
28
|
+
Legion::Logging.info 'Shutting down Legion::Cache::Local' if defined?(Legion::Logging)
|
|
29
|
+
@driver&.close
|
|
30
|
+
@driver = nil
|
|
31
|
+
@connected = false
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def connected?
|
|
35
|
+
@connected == true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def get(key)
|
|
39
|
+
@driver.get(key)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def set(key, value, ttl = 180)
|
|
43
|
+
@driver.set(key, value, ttl)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def fetch(key, ttl = nil)
|
|
47
|
+
@driver.fetch(key, ttl)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def delete(key)
|
|
51
|
+
@driver.delete(key)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def flush(delay = 0)
|
|
55
|
+
@driver.flush(delay)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def client
|
|
59
|
+
@driver&.client
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def close
|
|
63
|
+
@driver&.close
|
|
64
|
+
@connected = false
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def restart(**opts)
|
|
68
|
+
settings = local_settings
|
|
69
|
+
@driver&.restart(**settings.merge(opts))
|
|
70
|
+
@connected = true
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def size
|
|
74
|
+
@driver.size
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def available
|
|
78
|
+
@driver.available
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def pool_size
|
|
82
|
+
@driver.pool_size
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def timeout
|
|
86
|
+
@driver.timeout
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def reset!
|
|
90
|
+
@driver = nil
|
|
91
|
+
@connected = false
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
private
|
|
95
|
+
|
|
96
|
+
def build_driver(driver_name)
|
|
97
|
+
case driver_name
|
|
98
|
+
when 'redis'
|
|
99
|
+
require 'legion/cache/redis'
|
|
100
|
+
Legion::Cache::Redis.dup
|
|
101
|
+
else
|
|
102
|
+
require 'legion/cache/memcached'
|
|
103
|
+
Legion::Cache::Memcached.dup
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def local_settings
|
|
108
|
+
return Legion::Cache::Settings.local unless defined?(Legion::Settings)
|
|
109
|
+
|
|
110
|
+
Legion::Settings[:cache_local] || Legion::Cache::Settings.local
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'dalli'
|
|
2
4
|
require 'legion/cache/pool'
|
|
3
5
|
|
|
@@ -5,7 +7,7 @@ module Legion
|
|
|
5
7
|
module Cache
|
|
6
8
|
module Memcached
|
|
7
9
|
include Legion::Cache::Pool
|
|
8
|
-
extend self
|
|
10
|
+
extend self # rubocop:disable Style/ModuleFunction
|
|
9
11
|
|
|
10
12
|
def client(servers: Legion::Settings[:cache][:servers], **opts)
|
|
11
13
|
return @client unless @client.nil?
|
|
@@ -14,8 +16,11 @@ module Legion
|
|
|
14
16
|
@timeout = opts.key?(:timeout) ? opts[:timeout] : Legion::Settings[:cache][:timeout] || 5
|
|
15
17
|
|
|
16
18
|
Dalli.logger = Legion::Logging
|
|
19
|
+
cache_opts = Legion::Settings[:cache].merge(opts)
|
|
20
|
+
cache_opts[:value_max_bytes] ||= 8 * 1024 * 1024
|
|
21
|
+
|
|
17
22
|
@client = ConnectionPool.new(size: pool_size, timeout: timeout) do
|
|
18
|
-
Dalli::Client.new(servers,
|
|
23
|
+
Dalli::Client.new(servers, cache_opts)
|
|
19
24
|
end
|
|
20
25
|
|
|
21
26
|
@connected = true
|
|
@@ -23,19 +28,27 @@ module Legion
|
|
|
23
28
|
end
|
|
24
29
|
|
|
25
30
|
def get(key)
|
|
26
|
-
client.with { |conn| conn.get(key) }
|
|
31
|
+
result = client.with { |conn| conn.get(key) }
|
|
32
|
+
Legion::Logging.debug "[cache] GET #{key} hit=#{!result.nil?}"
|
|
33
|
+
result
|
|
27
34
|
end
|
|
28
35
|
|
|
29
36
|
def fetch(key, ttl = nil)
|
|
30
|
-
client.with { |conn| conn.fetch(key, ttl) }
|
|
37
|
+
result = client.with { |conn| conn.fetch(key, ttl) }
|
|
38
|
+
Legion::Logging.debug "[cache] FETCH #{key} hit=#{!result.nil?}"
|
|
39
|
+
result
|
|
31
40
|
end
|
|
32
41
|
|
|
33
42
|
def set(key, value, ttl = 180)
|
|
34
|
-
client.with { |conn| conn.set(key, value, ttl).positive? }
|
|
43
|
+
result = client.with { |conn| conn.set(key, value, ttl).positive? }
|
|
44
|
+
Legion::Logging.debug "[cache] SET #{key} ttl=#{ttl} success=#{result} value_class=#{value.class}"
|
|
45
|
+
result
|
|
35
46
|
end
|
|
36
47
|
|
|
37
48
|
def delete(key)
|
|
38
|
-
client.with { |conn| conn.delete(key) == true }
|
|
49
|
+
result = client.with { |conn| conn.delete(key) == true }
|
|
50
|
+
Legion::Logging.debug "[cache] DELETE #{key} success=#{result}"
|
|
51
|
+
result
|
|
39
52
|
end
|
|
40
53
|
|
|
41
54
|
def flush(delay = 0)
|
data/lib/legion/cache/pool.rb
CHANGED
data/lib/legion/cache/redis.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'redis'
|
|
2
4
|
require 'legion/cache/pool'
|
|
3
5
|
|
|
@@ -5,7 +7,7 @@ module Legion
|
|
|
5
7
|
module Cache
|
|
6
8
|
module Redis
|
|
7
9
|
include Legion::Cache::Pool
|
|
8
|
-
extend self
|
|
10
|
+
extend self # rubocop:disable Style/ModuleFunction
|
|
9
11
|
|
|
10
12
|
def client(pool_size: 20, timeout: 5, **)
|
|
11
13
|
return @client unless @client.nil?
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
begin
|
|
2
4
|
require 'legion/settings'
|
|
3
5
|
rescue StandardError
|
|
@@ -8,29 +10,48 @@ module Legion
|
|
|
8
10
|
module Cache
|
|
9
11
|
module Settings
|
|
10
12
|
Legion::Settings.merge_settings(:cache, default) if Legion::Settings.method_defined? :merge_settings
|
|
13
|
+
Legion::Settings.merge_settings(:cache_local, local) if Legion::Settings.method_defined? :merge_settings
|
|
11
14
|
def self.default
|
|
12
15
|
{
|
|
13
|
-
driver:
|
|
14
|
-
servers:
|
|
15
|
-
connected:
|
|
16
|
-
enabled:
|
|
17
|
-
namespace:
|
|
18
|
-
compress:
|
|
19
|
-
failover:
|
|
16
|
+
driver: driver,
|
|
17
|
+
servers: ['127.0.0.1:11211'],
|
|
18
|
+
connected: false,
|
|
19
|
+
enabled: true,
|
|
20
|
+
namespace: 'legion',
|
|
21
|
+
compress: false,
|
|
22
|
+
failover: true,
|
|
23
|
+
threadsafe: true,
|
|
24
|
+
expires_in: 0,
|
|
25
|
+
cache_nils: false,
|
|
26
|
+
pool_size: 10,
|
|
27
|
+
timeout: 5,
|
|
28
|
+
serializer: Legion::JSON
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.local
|
|
33
|
+
{
|
|
34
|
+
driver: driver,
|
|
35
|
+
servers: ['127.0.0.1:11211'],
|
|
36
|
+
connected: false,
|
|
37
|
+
enabled: true,
|
|
38
|
+
namespace: 'legion_local',
|
|
39
|
+
compress: false,
|
|
40
|
+
failover: true,
|
|
20
41
|
threadsafe: true,
|
|
21
42
|
expires_in: 0,
|
|
22
43
|
cache_nils: false,
|
|
23
|
-
pool_size:
|
|
24
|
-
timeout:
|
|
44
|
+
pool_size: 5,
|
|
45
|
+
timeout: 3,
|
|
25
46
|
serializer: Legion::JSON
|
|
26
47
|
}
|
|
27
48
|
end
|
|
28
49
|
|
|
29
50
|
def self.driver(prefer = 'dalli')
|
|
30
51
|
secondary = prefer == 'dalli' ? 'redis' : 'dalli'
|
|
31
|
-
if Gem::Specification.find_all_by_name(prefer).
|
|
52
|
+
if Gem::Specification.find_all_by_name(prefer).any?
|
|
32
53
|
prefer
|
|
33
|
-
elsif Gem::Specification.find_all_by_name(secondary).
|
|
54
|
+
elsif Gem::Specification.find_all_by_name(secondary).any?
|
|
34
55
|
secondary
|
|
35
56
|
else
|
|
36
57
|
raise NameError('Legion::Cache.driver is nil')
|
data/lib/legion/cache/version.rb
CHANGED
data/lib/legion/cache.rb
CHANGED
|
@@ -1,32 +1,101 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'legion/cache/version'
|
|
2
4
|
require 'legion/cache/settings'
|
|
3
5
|
|
|
4
6
|
require 'legion/cache/memcached'
|
|
5
7
|
require 'legion/cache/redis'
|
|
8
|
+
require 'legion/cache/local'
|
|
6
9
|
|
|
7
10
|
module Legion
|
|
8
11
|
module Cache
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
end
|
|
12
|
+
if Legion::Settings[:cache][:driver] == 'redis'
|
|
13
|
+
extend Legion::Cache::Redis
|
|
14
|
+
else
|
|
15
|
+
extend Legion::Cache::Memcached
|
|
16
|
+
end
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
class << self
|
|
19
|
+
def setup(**)
|
|
17
20
|
return Legion::Settings[:cache][:connected] = true if connected?
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@connected = true
|
|
22
|
-
Legion::Settings[:cache][:connected] = true
|
|
22
|
+
setup_local
|
|
23
|
+
setup_shared(**)
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
def shutdown
|
|
26
27
|
Legion::Logging.info 'Shutting down Legion::Cache'
|
|
27
|
-
close
|
|
28
|
+
close unless @using_local
|
|
29
|
+
Legion::Cache::Local.shutdown if Legion::Cache::Local.connected?
|
|
30
|
+
@using_local = false
|
|
31
|
+
@connected = false
|
|
28
32
|
Legion::Settings[:cache][:connected] = false
|
|
29
33
|
end
|
|
34
|
+
|
|
35
|
+
def local
|
|
36
|
+
Legion::Cache::Local
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def using_local?
|
|
40
|
+
@using_local == true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def get(key)
|
|
44
|
+
return Legion::Cache::Local.get(key) if @using_local
|
|
45
|
+
|
|
46
|
+
super
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def set(key, value, ttl = 180)
|
|
50
|
+
return Legion::Cache::Local.set(key, value, ttl) if @using_local
|
|
51
|
+
|
|
52
|
+
super
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def fetch(key, ttl = nil)
|
|
56
|
+
return Legion::Cache::Local.fetch(key, ttl) if @using_local
|
|
57
|
+
|
|
58
|
+
super
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def delete(key)
|
|
62
|
+
return Legion::Cache::Local.delete(key) if @using_local
|
|
63
|
+
|
|
64
|
+
super
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def flush(delay = 0)
|
|
68
|
+
return Legion::Cache::Local.flush(delay) if @using_local
|
|
69
|
+
|
|
70
|
+
super
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
private
|
|
74
|
+
|
|
75
|
+
def setup_local
|
|
76
|
+
return if Legion::Cache::Local.connected?
|
|
77
|
+
|
|
78
|
+
Legion::Cache::Local.setup
|
|
79
|
+
rescue StandardError => e
|
|
80
|
+
Legion::Logging.warn "Local cache setup failed: #{e.message}" if defined?(Legion::Logging)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def setup_shared(**)
|
|
84
|
+
client(**Legion::Settings[:cache], **)
|
|
85
|
+
@connected = true
|
|
86
|
+
@using_local = false
|
|
87
|
+
Legion::Settings[:cache][:connected] = true
|
|
88
|
+
rescue StandardError => e
|
|
89
|
+
Legion::Logging.warn "Shared cache unavailable (#{e.message}), falling back to Local" if defined?(Legion::Logging)
|
|
90
|
+
if Legion::Cache::Local.connected?
|
|
91
|
+
@using_local = true
|
|
92
|
+
@connected = true
|
|
93
|
+
Legion::Settings[:cache][:connected] = true
|
|
94
|
+
else
|
|
95
|
+
@connected = false
|
|
96
|
+
Legion::Settings[:cache][:connected] = false
|
|
97
|
+
end
|
|
98
|
+
end
|
|
30
99
|
end
|
|
31
100
|
end
|
|
32
101
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: legion-cache
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Esity
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: connection_pool
|
|
@@ -16,28 +15,28 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 2.
|
|
18
|
+
version: '2.4'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 2.
|
|
25
|
+
version: '2.4'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: dalli
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
30
|
- - ">="
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
32
|
+
version: '3.0'
|
|
34
33
|
type: :runtime
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
37
|
- - ">="
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
39
|
+
version: '3.0'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
41
|
name: legion-logging
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -72,60 +71,53 @@ dependencies:
|
|
|
72
71
|
requirements:
|
|
73
72
|
- - ">="
|
|
74
73
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
74
|
+
version: '5.0'
|
|
76
75
|
type: :runtime
|
|
77
76
|
prerelease: false
|
|
78
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
78
|
requirements:
|
|
80
79
|
- - ">="
|
|
81
80
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
81
|
+
version: '5.0'
|
|
83
82
|
description: A Wrapper class for the LegionIO framework to interface with both Memcached
|
|
84
83
|
and Redis for caching purposes
|
|
85
84
|
email:
|
|
86
85
|
- matthewdiverson@gmail.com
|
|
87
|
-
- ruby@optum.com
|
|
88
86
|
executables: []
|
|
89
87
|
extensions: []
|
|
90
88
|
extra_rdoc_files:
|
|
91
|
-
- README.md
|
|
92
|
-
- LICENSE
|
|
93
89
|
- CHANGELOG.md
|
|
90
|
+
- LICENSE
|
|
91
|
+
- README.md
|
|
94
92
|
files:
|
|
95
|
-
- ".github/workflows/
|
|
96
|
-
- ".github/workflows/sourcehawk-scan.yml"
|
|
93
|
+
- ".github/workflows/ci.yml"
|
|
97
94
|
- ".gitignore"
|
|
98
95
|
- ".rubocop.yml"
|
|
99
96
|
- CHANGELOG.md
|
|
100
|
-
-
|
|
101
|
-
- CONTRIBUTING.md
|
|
97
|
+
- CLAUDE.md
|
|
102
98
|
- Gemfile
|
|
103
|
-
- INDIVIDUAL_CONTRIBUTOR_LICENSE.md
|
|
104
99
|
- LICENSE
|
|
105
|
-
- NOTICE.txt
|
|
106
100
|
- README.md
|
|
107
|
-
- SECURITY.md
|
|
108
|
-
- attribution.txt
|
|
109
101
|
- legion-cache.gemspec
|
|
110
102
|
- lib/legion/cache.rb
|
|
103
|
+
- lib/legion/cache/local.rb
|
|
111
104
|
- lib/legion/cache/memcached.rb
|
|
112
105
|
- lib/legion/cache/pool.rb
|
|
113
106
|
- lib/legion/cache/redis.rb
|
|
114
107
|
- lib/legion/cache/settings.rb
|
|
115
108
|
- lib/legion/cache/version.rb
|
|
116
109
|
- sonar-project.properties
|
|
117
|
-
|
|
118
|
-
homepage: https://github.com/Optum/legion-cache
|
|
110
|
+
homepage: https://github.com/LegionIO/legion-cache
|
|
119
111
|
licenses:
|
|
120
112
|
- Apache-2.0
|
|
121
113
|
metadata:
|
|
122
|
-
bug_tracker_uri: https://github.com/
|
|
123
|
-
changelog_uri: https://github.com/
|
|
124
|
-
documentation_uri: https://github.com/
|
|
125
|
-
homepage_uri: https://github.com/
|
|
126
|
-
source_code_uri: https://github.com/
|
|
127
|
-
wiki_uri: https://github.com/
|
|
128
|
-
|
|
114
|
+
bug_tracker_uri: https://github.com/LegionIO/legion-cache/issues
|
|
115
|
+
changelog_uri: https://github.com/LegionIO/legion-cache/blob/main/CHANGELOG.md
|
|
116
|
+
documentation_uri: https://github.com/LegionIO/legion-cache
|
|
117
|
+
homepage_uri: https://github.com/LegionIO/LegionIO
|
|
118
|
+
source_code_uri: https://github.com/LegionIO/legion-cache
|
|
119
|
+
wiki_uri: https://github.com/LegionIO/legion-cache/wiki
|
|
120
|
+
rubygems_mfa_required: 'true'
|
|
129
121
|
rdoc_options: []
|
|
130
122
|
require_paths:
|
|
131
123
|
- lib
|
|
@@ -133,15 +125,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
133
125
|
requirements:
|
|
134
126
|
- - ">="
|
|
135
127
|
- !ruby/object:Gem::Version
|
|
136
|
-
version: '
|
|
128
|
+
version: '3.4'
|
|
137
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
130
|
requirements:
|
|
139
131
|
- - ">="
|
|
140
132
|
- !ruby/object:Gem::Version
|
|
141
133
|
version: '0'
|
|
142
134
|
requirements: []
|
|
143
|
-
rubygems_version: 3.
|
|
144
|
-
signing_key:
|
|
135
|
+
rubygems_version: 3.6.9
|
|
145
136
|
specification_version: 4
|
|
146
137
|
summary: Wraps both the redis and dalli gems to make a consistent interface for accessing
|
|
147
138
|
cached objects
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
name: Rubocop
|
|
2
|
-
on: [push, pull_request]
|
|
3
|
-
jobs:
|
|
4
|
-
rubocop:
|
|
5
|
-
strategy:
|
|
6
|
-
fail-fast: false
|
|
7
|
-
matrix:
|
|
8
|
-
os: [ubuntu-latest]
|
|
9
|
-
ruby: [2.7]
|
|
10
|
-
runs-on: ${{ matrix.os }}
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v2
|
|
13
|
-
- uses: ruby/setup-ruby@v1
|
|
14
|
-
with:
|
|
15
|
-
ruby-version: ${{ matrix.ruby }}
|
|
16
|
-
bundler-cache: true
|
|
17
|
-
- name: Install Rubocop
|
|
18
|
-
run: gem install rubocop code-scanning-rubocop
|
|
19
|
-
- name: Rubocop run --no-doc
|
|
20
|
-
run: |
|
|
21
|
-
bash -c "
|
|
22
|
-
rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
|
|
23
|
-
[[ $? -ne 2 ]]
|
|
24
|
-
"
|
|
25
|
-
- name: Upload Sarif output
|
|
26
|
-
uses: github/codeql-action/upload-sarif@v1
|
|
27
|
-
with:
|
|
28
|
-
sarif_file: rubocop.sarif
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
name: Sourcehawk Scan
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches:
|
|
5
|
-
- main
|
|
6
|
-
- master
|
|
7
|
-
pull_request:
|
|
8
|
-
branches:
|
|
9
|
-
- main
|
|
10
|
-
- master
|
|
11
|
-
jobs:
|
|
12
|
-
build:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v2
|
|
16
|
-
- name: Sourcehawk Scan
|
|
17
|
-
uses: optum/sourcehawk-scan-github-action@main
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
-
orientation.
|
|
11
|
-
|
|
12
|
-
## Our Standards
|
|
13
|
-
|
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
|
15
|
-
include:
|
|
16
|
-
|
|
17
|
-
* Using welcoming and inclusive language
|
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
|
19
|
-
* Gracefully accepting constructive criticism
|
|
20
|
-
* Focusing on what is best for the community
|
|
21
|
-
* Showing empathy towards other community members
|
|
22
|
-
|
|
23
|
-
Examples of unacceptable behavior by participants include:
|
|
24
|
-
|
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
-
advances
|
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
-
* Public or private harassment
|
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
|
30
|
-
address, without explicit permission
|
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
-
professional setting
|
|
33
|
-
|
|
34
|
-
## Our Responsibilities
|
|
35
|
-
|
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
-
response to any instances of unacceptable behavior.
|
|
39
|
-
|
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
-
threatening, offensive, or harmful.
|
|
45
|
-
|
|
46
|
-
## Scope
|
|
47
|
-
|
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
-
when an individual is representing the project or its community. Examples of
|
|
50
|
-
representing a project or community include using an official project email
|
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
|
53
|
-
further defined and clarified by project maintainers.
|
|
54
|
-
|
|
55
|
-
## Enforcement
|
|
56
|
-
|
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
-
reported by contacting the project team at [opensource@optum.com][email]. All
|
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
|
63
|
-
|
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
-
members of the project's leadership.
|
|
67
|
-
|
|
68
|
-
## Attribution
|
|
69
|
-
|
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
-
|
|
73
|
-
[homepage]: http://contributor-covenant.org
|
|
74
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
|
75
|
-
[email]: mailto:opensource@optum.com
|
data/CONTRIBUTING.md
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# Contribution Guidelines
|
|
2
|
-
|
|
3
|
-
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms. Please also review our [Contributor License Agreement ("CLA")](INDIVIDUAL_CONTRIBUTOR_LICENSE.md) prior to submitting changes to the project. You will need to attest to this agreement following the instructions in the [Paperwork for Pull Requests](#paperwork-for-pull-requests) section below.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# How to Contribute
|
|
8
|
-
|
|
9
|
-
Now that we have the disclaimer out of the way, let's get into how you can be a part of our project. There are many different ways to contribute.
|
|
10
|
-
|
|
11
|
-
## Issues
|
|
12
|
-
|
|
13
|
-
We track our work using Issues in GitHub. Feel free to open up your own issue to point out areas for improvement or to suggest your own new experiment. If you are comfortable with signing the waiver linked above and contributing code or documentation, grab your own issue and start working.
|
|
14
|
-
|
|
15
|
-
## Coding Standards
|
|
16
|
-
|
|
17
|
-
We have some general guidelines towards contributing to this project.
|
|
18
|
-
Please run RSpec and Rubocop while developing code for LegionIO
|
|
19
|
-
|
|
20
|
-
### Languages
|
|
21
|
-
|
|
22
|
-
*Ruby*
|
|
23
|
-
|
|
24
|
-
## Pull Requests
|
|
25
|
-
|
|
26
|
-
If you've gotten as far as reading this section, then thank you for your suggestions.
|
|
27
|
-
|
|
28
|
-
## Paperwork for Pull Requests
|
|
29
|
-
|
|
30
|
-
* Please read this guide and make sure you agree with our [Contributor License Agreement ("CLA")](INDIVIDUAL_CONTRIBUTOR_LICENSE.md).
|
|
31
|
-
* Make sure git knows your name and email address:
|
|
32
|
-
```
|
|
33
|
-
$ git config user.name "J. Random User"
|
|
34
|
-
$ git config user.email "j.random.user@example.com"
|
|
35
|
-
```
|
|
36
|
-
>The name and email address must be valid as we cannot accept anonymous contributions.
|
|
37
|
-
* Write good commit messages.
|
|
38
|
-
> Concise commit messages that describe your changes help us better understand your contributions.
|
|
39
|
-
* The first time you open a pull request in this repository, you will see a comment on your PR with a link that will allow you to sign our Contributor License Agreement (CLA) if necessary.
|
|
40
|
-
> The link will take you to a page that allows you to view our CLA. You will need to click the `Sign in with GitHub to agree button` and authorize the cla-assistant application to access the email addresses associated with your GitHub account. Agreeing to the CLA is also considered to be an attestation that you either wrote or have the rights to contribute the code. All committers to the PR branch will be required to sign the CLA, but you will only need to sign once. This CLA applies to all repositories in the Optum org.
|
|
41
|
-
|
|
42
|
-
## General Guidelines
|
|
43
|
-
|
|
44
|
-
Ensure your pull request (PR) adheres to the following guidelines:
|
|
45
|
-
|
|
46
|
-
* Try to make the name concise and descriptive.
|
|
47
|
-
* Give a good description of the change being made. Since this is very subjective, see the [Updating Your Pull Request (PR)](#updating-your-pull-request-pr) section below for further details.
|
|
48
|
-
* Every pull request should be associated with one or more issues. If no issue exists yet, please create your own.
|
|
49
|
-
* Make sure that all applicable issues are mentioned somewhere in the PR description. This can be done by typing # to bring up a list of issues.
|
|
50
|
-
|
|
51
|
-
### Updating Your Pull Request (PR)
|
|
52
|
-
|
|
53
|
-
A lot of times, making a PR adhere to the standards above can be difficult. If the maintainers notice anything that we'd like changed, we'll ask you to edit your PR before we merge it. This applies to both the content documented in the PR and the changed contained within the branch being merged. There's no need to open a new PR. Just edit the existing one.
|
|
54
|
-
|
|
55
|
-
[email]: mailto:opensource@optum.com
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Individual Contributor License Agreement ("Agreement") V2.0
|
|
2
|
-
|
|
3
|
-
Thank you for your interest in this Optum project (the "PROJECT"). In order to clarify the intellectual property license granted with Contributions from any person or entity, the PROJECT must have a Contributor License Agreement ("CLA") on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of the PROJECT and its users; it does not change your rights to use your own Contributions for any other purpose.
|
|
4
|
-
|
|
5
|
-
You accept and agree to the following terms and conditions for Your present and future Contributions submitted to the PROJECT. In return, the PROJECT shall not use Your Contributions in a way that is inconsistent with stated project goals in effect at the time of the Contribution. Except for the license granted herein to the PROJECT and recipients of software distributed by the PROJECT, You reserve all right, title, and interest in and to Your Contributions.
|
|
6
|
-
1. Definitions.
|
|
7
|
-
|
|
8
|
-
"You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with the PROJECT. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
9
|
-
|
|
10
|
-
"Contribution" shall mean any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to the PROJECT for inclusion in, or documentation of, any of the products owned or managed by the PROJECT (the "Work"). For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the PROJECT or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the PROJECT for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution."
|
|
11
|
-
|
|
12
|
-
2. Grant of Copyright License.
|
|
13
|
-
|
|
14
|
-
Subject to the terms and conditions of this Agreement, You hereby grant to the PROJECT and to recipients of software distributed by the PROJECT a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works.
|
|
15
|
-
|
|
16
|
-
3. Grant of Patent License.
|
|
17
|
-
|
|
18
|
-
Subject to the terms and conditions of this Agreement, You hereby grant to the PROJECT and to recipients of software distributed by the PROJECT a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed.
|
|
19
|
-
|
|
20
|
-
4. Representations.
|
|
21
|
-
|
|
22
|
-
(a) You represent that you are legally entitled to grant the above license. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer, that your employer has waived such rights for your Contributions to the PROJECT, or that your employer has executed a separate Corporate CLA with the PROJECT.
|
|
23
|
-
|
|
24
|
-
(b) You represent that each of Your Contributions is Your original creation (see section 6 for submissions on behalf of others). You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions.
|
|
25
|
-
|
|
26
|
-
5. You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
|
|
27
|
-
|
|
28
|
-
6. Should You wish to submit work that is not Your original creation, You may submit it to the PROJECT separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as "Submitted on behalf of a third-party: [named here]".
|
|
29
|
-
|
|
30
|
-
7. You agree to notify the PROJECT of any facts or circumstances of which you become aware that would make these representations inaccurate in any respect.
|
data/NOTICE.txt
DELETED
data/SECURITY.md
DELETED
data/attribution.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Add attributions here.
|
data/sourcehawk.yml
DELETED