solid_cache 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +268 -0
- data/Rakefile +8 -0
- data/app/jobs/solid_cache/expiry_job.rb +9 -0
- data/app/models/solid_cache/entry.rb +157 -0
- data/app/models/solid_cache/record.rb +27 -0
- data/db/migrate/20230724121448_create_solid_cache_entries.rb +11 -0
- data/lib/active_support/cache/solid_cache_store.rb +5 -0
- data/lib/generators/solid_cache/install/USAGE +9 -0
- data/lib/generators/solid_cache/install/install_generator.rb +18 -0
- data/lib/solid_cache/cluster/connections.rb +51 -0
- data/lib/solid_cache/cluster/execution.rb +52 -0
- data/lib/solid_cache/cluster/expiry.rb +61 -0
- data/lib/solid_cache/cluster/stats.rb +32 -0
- data/lib/solid_cache/cluster.rb +14 -0
- data/lib/solid_cache/connections/sharded.rb +40 -0
- data/lib/solid_cache/connections/single.rb +37 -0
- data/lib/solid_cache/connections/unmanaged.rb +31 -0
- data/lib/solid_cache/connections.rb +31 -0
- data/lib/solid_cache/engine.rb +20 -0
- data/lib/solid_cache/maglev_hash.rb +77 -0
- data/lib/solid_cache/store/api.rb +153 -0
- data/lib/solid_cache/store/clusters.rb +85 -0
- data/lib/solid_cache/store/entries.rb +81 -0
- data/lib/solid_cache/store/failsafe.rb +28 -0
- data/lib/solid_cache/store.rb +18 -0
- data/lib/solid_cache/version.rb +3 -0
- data/lib/solid_cache.rb +33 -0
- data/lib/tasks/solid_cache_tasks.rake +6 -0
- metadata +116 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
module SolidCache
|
2
|
+
class Store < ActiveSupport::Cache::Store
|
3
|
+
include Api, Clusters, Entries, Failsafe
|
4
|
+
prepend ActiveSupport::Cache::Strategy::LocalCache
|
5
|
+
|
6
|
+
def self.supports_cache_versioning?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
|
10
|
+
def setup!
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def stats
|
15
|
+
primary_cluster.stats
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/solid_cache.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "zeitwerk"
|
2
|
+
require "solid_cache/engine"
|
3
|
+
|
4
|
+
loader = Zeitwerk::Loader.for_gem
|
5
|
+
loader.ignore("#{__dir__}/active_support")
|
6
|
+
loader.ignore("#{__dir__}/generators")
|
7
|
+
loader.setup
|
8
|
+
|
9
|
+
module SolidCache
|
10
|
+
mattr_accessor :executor, :connects_to
|
11
|
+
|
12
|
+
def self.all_shard_keys
|
13
|
+
all_shards_config&.keys || []
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.all_shards_config
|
17
|
+
connects_to && connects_to[:shards]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.each_shard
|
21
|
+
return to_enum(:each_shard) unless block_given?
|
22
|
+
|
23
|
+
if (shards = all_shards_config&.keys)
|
24
|
+
shards.each do |shard|
|
25
|
+
Record.connected_to(shard: shard) { yield }
|
26
|
+
end
|
27
|
+
else
|
28
|
+
yield
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
loader.eager_load
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: solid_cache
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Donal McBreen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-10-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: debug
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mocha
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A database backed ActiveSupport::Cache::Store
|
56
|
+
email:
|
57
|
+
- donal@37signals.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- app/jobs/solid_cache/expiry_job.rb
|
66
|
+
- app/models/solid_cache/entry.rb
|
67
|
+
- app/models/solid_cache/record.rb
|
68
|
+
- db/migrate/20230724121448_create_solid_cache_entries.rb
|
69
|
+
- lib/active_support/cache/solid_cache_store.rb
|
70
|
+
- lib/generators/solid_cache/install/USAGE
|
71
|
+
- lib/generators/solid_cache/install/install_generator.rb
|
72
|
+
- lib/solid_cache.rb
|
73
|
+
- lib/solid_cache/cluster.rb
|
74
|
+
- lib/solid_cache/cluster/connections.rb
|
75
|
+
- lib/solid_cache/cluster/execution.rb
|
76
|
+
- lib/solid_cache/cluster/expiry.rb
|
77
|
+
- lib/solid_cache/cluster/stats.rb
|
78
|
+
- lib/solid_cache/connections.rb
|
79
|
+
- lib/solid_cache/connections/sharded.rb
|
80
|
+
- lib/solid_cache/connections/single.rb
|
81
|
+
- lib/solid_cache/connections/unmanaged.rb
|
82
|
+
- lib/solid_cache/engine.rb
|
83
|
+
- lib/solid_cache/maglev_hash.rb
|
84
|
+
- lib/solid_cache/store.rb
|
85
|
+
- lib/solid_cache/store/api.rb
|
86
|
+
- lib/solid_cache/store/clusters.rb
|
87
|
+
- lib/solid_cache/store/entries.rb
|
88
|
+
- lib/solid_cache/store/failsafe.rb
|
89
|
+
- lib/solid_cache/version.rb
|
90
|
+
- lib/tasks/solid_cache_tasks.rake
|
91
|
+
homepage: http://github.com/rails/solid_cache
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata:
|
95
|
+
homepage_uri: http://github.com/rails/solid_cache
|
96
|
+
source_code_uri: http://github.com/rails/solid_cache
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubygems_version: 3.4.17
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: A database backed ActiveSupport::Cache::Store
|
116
|
+
test_files: []
|