solid_cache_mongoid 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf9d5857f9532ff873ca0667c47e572d61ccaee958a9768d0bf372832ed45067
4
- data.tar.gz: 2e6a812dd2b7930ddf81f7f1cddbf08cef0cf039365f974412b7460642964ee4
3
+ metadata.gz: a0a03bc074cafd74ca8702ecf9adbe0ebff49846a848d4d11d2acb3ed304547e
4
+ data.tar.gz: f8394194bdddca35cf85f46bbcd556e5b10e4342f5c45930d695ff780dcbc942
5
5
  SHA512:
6
- metadata.gz: 1355e87bd9234e18d12a7a33fb70d9145be98088fa1117f983110a998fe5ec5f2857e8baf1d826a601112c224839e4e37ff0f0d738f04709ecdb550173032da2
7
- data.tar.gz: 86dc49c94645cf8c6ecdc5c5d69ead576bf15ed66d3ecf0629952f7c49db7beafa3c181e993e3b4050a02ba0cdc50cb03931a79518315b71d03b3574c82e30a6
6
+ metadata.gz: 947dd55858789b134d31497476cb2881153a14576c86fa2cf27d56aadbd867215d53a78faf66660f930a20648eaf2e961d28b4aafffe3179dbcc6bd611a86a28
7
+ data.tar.gz: 1241fc8dbe3dfca7f5e0206ad42b795ebe2a328cd9ecd5d31e615311c9aac343068f5434e5c95d68b7bb0fb4d5aee056a5ebc044e9e39e9869e9a3d156ea628a
data/README.md CHANGED
@@ -1,189 +1,163 @@
1
- # Solid Cache
1
+ # Solid Cache for Mongoid
2
2
 
3
- Solid Cache is a database-backed Active Support cache store that lets you keep a much larger cache than is typically possible with traditional memory-only Redis or Memcached stores. This is thanks to the speed of modern SSD drives, which make the access-time penalty of using disk vs RAM insignificant for most caching purposes. Simply put, you're now usually better off keeping a huge cache on disk rather than a small cache in memory.
3
+ [![Gem Version](https://img.shields.io/gem/v/solid_cache_mongoid?style=flat-square)](https://rubygems.org/gems/solid_cache_mongoid)
4
+ [![Downloads](https://img.shields.io/gem/dt/solid_cache_mongoid?style=flat-square)](https://rubygems.org/gems/solid_cache_mongoid)
5
+ [![License](https://img.shields.io/github/license/duvanherfi/solid_cache_mongoid?style=flat-square)](MIT-LICENSE)
4
6
 
5
- ## Installation
6
-
7
- Solid Cache is configured by default in new Rails 8 applications. But if you're running an earlier version, you can add it manually following these steps:
8
-
9
- 1. `bundle add solid_cache_mongoid`
10
- 2. `bin/rails solid_cache_mongoid:install`
11
-
12
- This will configure Solid Cache as the production cache store and create `config/cache.yml`.
13
-
14
- ## Configuration
7
+ A database-backed `ActiveSupport::Cache::Store` for Rails applications that run
8
+ on **MongoDB**.
15
9
 
16
- Configuration will be read from `config/cache.yml` or `config/solid_cache.yml`. You can change the location of the config file by setting the `SOLID_CACHE_CONFIG` env variable.
10
+ Rails 8 ships [Solid Cache](https://github.com/rails/solid_cache), which trades
11
+ RAM for disk: modern SSDs are fast enough that a large cache on disk beats a
12
+ small cache in memory for most workloads. But Solid Cache is built on Active
13
+ Record. An application backed by Mongoid cannot use it, and gets pushed onto
14
+ Redis or Memcached for caching alone — one more service to run, pay for, and be
15
+ paged about.
17
16
 
18
- The format of the file is:
19
-
20
- ```yml
21
- default: &default
22
- # database: <%= ENV.fetch("SOLID_CACHE_DATABASE", "solid_cache") %>
23
- # collection: solid_cache_entries
24
- # client: default
25
- # encrypt: false
26
- store_options:
27
- # Cap age of oldest cache entry to fulfill retention policies
28
- # max_age: <%%= 60.days.to_i %>
29
- max_size: <%%= 256.megabytes %>
30
- namespace: <%%= Rails.env %>
31
-
32
- development:
33
- <<: *default
17
+ This is Solid Cache rewritten on Mongoid, so those applications can cache
18
+ against the database they already have.
34
19
 
35
- test:
36
- <<: *default
37
-
38
- production:
39
- database: <%= ENV.fetch("SOLID_CACHE_DATABASE", "solid_cache") %>
40
- <<: *default
41
-
42
- ```
43
-
44
- For the full list of keys for `store_options` see [Cache configuration](#cache-configuration). Any options passed to the cache lookup will overwrite those specified here.
45
-
46
- After running `solid_cache:install`, `environments/production.rb` will replace your cache store with Solid Cache, but you can also do this manually:
20
+ ## Installation
47
21
 
48
22
  ```ruby
49
- # config/environments/production.rb
50
- config.cache_store = :solid_cache_mongoid_store
23
+ # Gemfile
24
+ gem "solid_cache_mongoid"
51
25
  ```
52
- ### Engine configuration
53
-
54
- There are five options that can be set on the engine:
55
-
56
- - `executor` - the [Rails executor](https://guides.rubyonrails.org/threading_and_code_execution.html#executor) used to wrap asynchronous operations, defaults to the app executor
57
- - `size_estimate_samples` - if `max_size` is set on the cache, the number of the samples used to estimate the size.
58
- - `encrypted` - whether cache values should be encrypted (see [Enabling encryption](#enabling-encryption))
59
- - `encryption_context_properties` - custom encryption context properties
60
26
 
61
- These can be set in your Rails configuration:
62
-
63
- ```ruby
64
- Rails.application.configure do
65
- config.solid_cache.size_estimate_samples = 1000
66
- end
27
+ ```sh
28
+ bundle install
29
+ bin/rails generate solid_cache_mongoid:install
67
30
  ```
68
31
 
69
- ### Cache configuration
70
-
71
- Solid Cache supports these options in addition to the standard `ActiveSupport::Cache::Store` options:
32
+ The generator writes `config/cache.yml` and points `config.cache_store` at
33
+ `:solid_cache_mongoid_store` in development, test and production.
72
34
 
73
- - `error_handler` - a Proc to call to handle any transient database errors that are raised (default: log errors as warnings)
74
- - `expiry_batch_size` - the batch size to use when deleting old records (default: `100`)
75
- - `expiry_method` - what expiry method to use `thread` or `job` (default: `thread`)
76
- - `expiry_queue` - which queue to add expiry jobs to (default: `default`)
77
- - `max_age` - the maximum age of entries in the cache (default: `2.weeks.to_i`). Can be set to `nil`, but this is not recommended unless using `max_entries` to limit the size of the cache.
78
- - `max_entries` - the maximum number of entries allowed in the cache (default: `nil`, meaning no limit)
79
- - `max_size` - the maximum size of the cache entries (default `nil`, meaning no limit)
80
- - `cluster` - (deprecated) a Hash of options for the cache database cluster, e.g `{ shards: [:database1, :database2, :database3] }`
81
- - `clusters` - (deprecated) an Array of Hashes for multiple cache clusters (ignored if `:cluster` is set)
82
- - `shards` - an Array of databases
83
- - `active_record_instrumentation` - whether to instrument the cache's queries (default: `true`)
84
- - `clear_with` - clear the cache with `:truncate` or `:delete` (default `truncate`, except for when `Rails.env.test?` then `delete`)
85
- - `max_key_bytesize` - the maximum size of a normalized key in bytes (default `1024`)
35
+ There is no migration to run. The collection is created on first write and the
36
+ indexes are declared on the model a unique index on `key_hash` for lookups,
37
+ plus `byte_size` and a compound `key_hash + byte_size` used by size estimation.
86
38
 
87
- ## Cache expiry
39
+ Requires Rails >= 7.2 (< 8.1) and Mongoid >= 9.
88
40
 
89
- Solid Cache tracks writes to the cache. For every write it increments a counter by 1. Once the counter reaches 50% of the `expiry_batch_size` it adds a task to run on a background thread. That task will:
90
-
91
- 1. Check if we have exceeded the `max_entries` or `max_size` values (if set).
92
- The current entries are estimated by subtracting the max and min IDs from the `SolidCache::Entry` table.
93
- The current size is estimated by sampling the entry `byte_size` columns.
94
- 2. If we have, it will delete `expiry_batch_size` entries.
95
- 3. If not, it will delete up to `expiry_batch_size` entries, provided they are all older than `max_age`.
96
-
97
- Expiring when we reach 50% of the batch size allows us to expire records from the cache faster than we write to it when we need to reduce the cache size.
41
+ ## Configuration
98
42
 
99
- Only triggering expiry when we write means that if the cache is idle, the background thread is also idle.
43
+ The cache always lives in its own Mongo database `solid_cache_mongoid` unless
44
+ you name another one — in a `solid_cache_entries` collection. It never shares
45
+ the application's database, so cache traffic and application traffic can be
46
+ pointed at different clients, and dropping the cache can never touch business
47
+ data.
100
48
 
101
- If you want the cache expiry to be run in a background job instead of a thread, you can set `expiry_method` to `:job`. This will enqueue a `SolidCache::ExpiryJob`.
49
+ `config/cache.yml`:
102
50
 
103
- ## Enabling encryption
51
+ ```yaml
52
+ default: &default
53
+ database: solid_cache_mongoid
54
+ store_options:
55
+ max_age: <%= 60.days.to_i %>
56
+ max_size: <%= 256.megabytes %>
57
+ namespace: <%= Rails.env %>
104
58
 
105
- To encrypt the cache values, you can add the encrypt property.
59
+ development:
60
+ <<: *default
106
61
 
107
- ```yaml
108
- # config/cache.yml
109
62
  production:
110
- encrypt: true
111
- ```
112
- or
113
- ```ruby
114
- # application.rb
115
- config.solid_cache.encrypt = true
63
+ <<: *default
116
64
  ```
117
65
 
118
- You will need to set up your application to [use Active Record Encryption](https://www.mongodb.com/docs/mongoid/current/security/encryption).
66
+ Top-level options:
119
67
 
120
- Solid Cache by default uses a custom encryptor and message serializer that are optimised for it.
121
- You can choose your own context properties instead if you prefer:
68
+ | Option | Default | What it does |
69
+ |---|---|---|
70
+ | `database` | `solid_cache_mongoid` | Mongo database holding the cache. |
71
+ | `collection` | `solid_cache_entries` | Collection name. |
72
+ | `client` | — | Mongoid client to use, if not the default one. |
73
+ | `encrypt` | `false` | Encrypt keys and values at rest. |
74
+ | `encryption_context_properties` | `{ deterministic: false }` | Passed to Mongoid encryption. |
75
+ | `size_estimate_samples` | `10_000` | Documents sampled when estimating cache size. |
122
76
 
123
- ```ruby
124
- # application.rb
125
- config.solid_cache.encryption_context_properties = {
126
- deterministic: false
127
- }
128
- ```
77
+ `store_options` are handed to the cache store itself: `max_age`, `max_size`,
78
+ `max_entries`, `namespace`, `expiry_batch_size`, `expiry_method`,
79
+ `expiry_queue`.
129
80
 
130
- ## Index size limits
131
- The Solid Cache migrations try to create an index with 1024 byte entries. If that is too big for your database, you should:
81
+ ### Encryption at rest
132
82
 
133
- 1. Edit the index size in the migration.
134
- 2. Set `max_key_bytesize` on your cache to the new value.
83
+ Setting `encrypt: true` turns on Mongoid field encryption for `key` and
84
+ `value`, keyed from `SOLID_CACHE_KEY_ENCRYPT` or, absent that, the
85
+ application's `secret_key_base`. Encryption is non-deterministic by default:
86
+ the same value encrypts differently each time, so an attacker reading the
87
+ collection cannot tell which entries hold the same content.
135
88
 
136
- ## Development
89
+ ## How expiry works
137
90
 
138
- Run the tests with `bin/rake test`. By default, these will run against SQLite.
91
+ Expiry is not a cron job. Writes trigger it probabilistically, so the cache
92
+ trims itself in proportion to how hard it is being used and an idle
93
+ application does no work at all.
139
94
 
140
- You can also run the tests against MySQL and PostgreSQL. First start up the databases:
95
+ Each pass asks for three times as many candidates as it intends to delete and
96
+ then randomly samples down to the real count. That is deliberate: with several
97
+ workers expiring concurrently, taking the first N of an ordered list means
98
+ every worker fights over the same documents. Oversampling and choosing at
99
+ random keeps their working sets mostly disjoint.
141
100
 
142
- ```shell
143
- $ docker compose up -d
144
- ```
101
+ Candidates are ordered by `_id`. A BSON `ObjectId` begins with a 4-byte
102
+ timestamp, so `_id` order is creation order — the same property upstream gets
103
+ from an autoincrementing primary key — which means age-based expiry needs no
104
+ index on `created_at`.
145
105
 
146
- Next, setup the database:
106
+ ## What is different from upstream Solid Cache
147
107
 
148
- ```shell
149
- $ bin/rails db:setup
150
- ```
108
+ The port is not a search-and-replace of `ApplicationRecord` for a Mongoid
109
+ model. The parts of Solid Cache that lean on SQL semantics had to be rebuilt.
151
110
 
111
+ **Locking.** Upstream uses Active Record transactions and database advisory
112
+ locks so concurrent expiry passes do not collide. MongoDB has no advisory
113
+ locks, so this uses [`mongoid-locker`](https://github.com/mongoid/mongoid-locker),
114
+ which takes a document-level lock through `locking_name` and `locked_at`
115
+ fields on the entry itself.
152
116
 
153
- Then run the tests:
117
+ **Binary storage.** Keys and values are `BSON::Binary`, not SQL `BLOB`
118
+ columns, and are unwrapped on read. Serialized cache values are arbitrary
119
+ bytes; letting BSON infer a type would corrupt them.
154
120
 
155
- ```shell
156
- $ bin/rake test
157
- ```
121
+ **Key hashing.** Lookups match on a 64-bit hash of the key, clamped to
122
+ `-(2**63)..(2**63 - 1)` so it fits BSON's `int64`. The index stays small and
123
+ fixed-width regardless of how long the application's cache keys are. The hash
124
+ is also uniformly distributed, which is what makes the sampling below work.
158
125
 
159
- ### Testing with multiple Rails versions
126
+ **Row counting.** Upstream estimates how many rows the table holds by
127
+ subtracting the smallest primary key from the largest — cheap and accurate
128
+ with an autoincrementing integer. ObjectIds are not subtractable that way, so
129
+ this port counts documents instead.
160
130
 
161
- Solid Cache relies on [appraisal](https://github.com/thoughtbot/appraisal/tree/main) to test
162
- multiple Rails versions.
131
+ **Query cache.** `without_query_cache` maps onto `Mongo::QueryCache.uncached`
132
+ rather than Active Record's connection-level query cache.
163
133
 
164
- To run a test for a specific version run:
134
+ **Sharding.** Upstream can spread the cache across several databases through
135
+ `connects_to`. This port runs against a single unmanaged connection.
136
+ Applications that need to shard should shard in MongoDB.
165
137
 
166
- ```shell
167
- bundle exec appraisal rails-7-1 bin/rake test
168
- ```
138
+ ## Size estimation
169
139
 
170
- After updating the dependencies in the `Gemfile` please run:
140
+ Storing a `byte_size` per document makes the total cache size estimable
141
+ without scanning the collection:
171
142
 
172
- ```shell
173
- $ bundle
174
- $ appraisal update
175
- ```
143
+ 1. Take the N largest documents by `byte_size` — there is an index for it — and
144
+ sum them exactly. These are the outliers that would otherwise skew any
145
+ sample.
146
+ 2. Use the smallest of those as a cutoff, and sample the rest through a random
147
+ window of the `key_hash` range. Because `key_hash` is uniformly distributed
148
+ and indexed together with `byte_size`, the sum comes straight out of the
149
+ index.
150
+ 3. Scale the sampled sum back up by the sampling fraction and add the outliers.
176
151
 
177
- This ensures that all the Rails versions dependencies are updated.
152
+ The result is an estimate whose cost does not grow with the size of the cache.
178
153
 
179
- ## Implementation
154
+ ## Batching
180
155
 
181
- Solid Cache is a FIFO (first in, first out) cache. While this is not as efficient as an LRU (least recently used) cache, it is mitigated by the longer cache lifespan.
156
+ `read_multi` and `write_multi` slice their input into batches of 1000, so a
157
+ wide `fetch_multi` costs a handful of round trips instead of one per key.
182
158
 
183
- A FIFO cache is much easier to manage:
184
- 1. We don't need to track when items are read.
185
- 2. We can estimate and control the cache size by comparing the maximum and minimum IDs.
186
- 3. By deleting from one end of the table and adding at the other end we can avoid fragmentation.
159
+ ## Credit
187
160
 
188
- ## License
189
- Solid Cache is licensed under MIT.
161
+ Original Solid Cache by [Donal McBreen](https://github.com/djmb) and 37signals.
162
+ Mongoid port by [Duvan Hernandez](https://github.com/duvanherfi). MIT licensed,
163
+ same as upstream.
@@ -21,8 +21,9 @@ module SolidCacheMongoid
21
21
  # on key_hash and byte_size so we can grab a sum of the byte_sizes in a range of key_hash directly from that
22
22
  # index.
23
23
  #
24
- # To decide how big the range should be, we use the difference between the smallest and largest database IDs as
25
- # an estimate of the number of rows in the table. This should be a good estimate, because we delete rows in ID order
24
+ # To decide how big the range should be, we need the number of documents in the collection. Upstream Solid Cache
25
+ # subtracts the smallest primary key from the largest, which is cheap and accurate with an autoincrementing integer.
26
+ # ObjectIds cannot be subtracted that way, so here Entry.id_range counts the documents instead.
26
27
  #
27
28
  # We then calculate the fraction of the rows we want to sample by dividing the sample size by the estimated number
28
29
  # of rows.
@@ -38,7 +39,7 @@ module SolidCacheMongoid
38
39
  # outliers_cutoff OC = min(byte_size of N largest rows)
39
40
  # outliers_size OS = sum(byte_size of N largest rows)
40
41
  #
41
- # estimated number of rows R = max(ID) - min(ID) + 1
42
+ # estimated number of rows R = number of documents in the collection
42
43
  # sample_fraction F = N / R
43
44
  # sample_range_size S = (Kmax - Kmin) * F
44
45
  # sample range is K1..K2 where K1 = Kmin + rand(Kmax - S) and K2 = K1 + S
@@ -80,7 +81,7 @@ module SolidCacheMongoid
80
81
  @outlier_size_and_cutoff ||= Entry.uncached do
81
82
  largest = Entry.largest_byte_sizes(samples)
82
83
 
83
- # Usar agregación de MongoDB para calcular sum, count y min
84
+ # Let MongoDB aggregate the sum, count and min
84
85
  if largest.exists?
85
86
  sum = largest.sum(:byte_size)
86
87
  count = largest.count
@@ -32,7 +32,7 @@ module SolidCacheMongoid
32
32
  value = Entry.read(ESTIMATES_KEY)
33
33
  return [] unless value
34
34
 
35
- # Convertir de BSON::Binary a string si es necesario
35
+ # Unwrap BSON::Binary into a string when needed
36
36
  value_str = value.is_a?(BSON::Binary) ? value.data : value.to_s
37
37
  value_str.presence&.split("|")&.map(&:to_i) || []
38
38
  end
@@ -28,7 +28,7 @@ module SolidCacheMongoid
28
28
  without_query_cache do
29
29
  payloads.each_slice(MULTI_BATCH_SIZE).each do |payload_batch|
30
30
  add_key_hash_and_byte_size(payload_batch).each do |payload|
31
- # Convertir key y value a BSON::Binary
31
+ # Store key and value as BSON::Binary
32
32
  key = payload.delete(:key)
33
33
  value = payload.delete(:value)
34
34
  obj = where(key_hash: payload[:key_hash]).first_or_initialize
@@ -54,7 +54,7 @@ module SolidCacheMongoid
54
54
  where(:key_hash.in => key_hashes)
55
55
  .only(:key, :value)
56
56
  .each do |entry|
57
- # Convertir BSON::Binary de vuelta a string
57
+ # Unwrap BSON::Binary back into a string
58
58
  key_str = entry.key.data
59
59
  value_str = entry.value.data
60
60
  results[key_str] = value_str
@@ -42,7 +42,7 @@ module SolidCacheMongoid
42
42
  ActiveSupport::Notifications.instrumenter = old
43
43
  end
44
44
  else
45
- # Fallback al comportamiento previo que usaba IsolatedExecutionState
45
+ # Fall back to the previous behaviour, which used IsolatedExecutionState
46
46
  old = ActiveSupport::IsolatedExecutionState[:active_record_instrumenter]
47
47
  ActiveSupport::IsolatedExecutionState[:active_record_instrumenter] = instrumenter
48
48
  begin
@@ -64,10 +64,10 @@ module SolidCacheMongoid
64
64
  alias :cache :with_query_cache
65
65
 
66
66
  def lease_connection
67
- # Obtiene el cliente Mongo actual del modelo
67
+ # The model's current Mongo client
68
68
  client = self.mongo_client
69
69
 
70
- # Asegura que hay una conexión disponible
70
+ # Make sure a connection is available
71
71
  client.reconnect unless client.cluster.connected?
72
72
 
73
73
  yield client
@@ -1,5 +1,5 @@
1
1
  default: &default
2
- # database: <%= ENV.fetch("SOLID_CACHE_DATABASE", "solid_cache") %>
2
+ # database: <%= ENV.fetch("SOLID_CACHE_DATABASE", "solid_cache_mongoid") %>
3
3
  # collection: solid_cache_entries
4
4
  # client: default
5
5
  # encrypt: false
@@ -16,5 +16,5 @@ test:
16
16
  <<: *default
17
17
 
18
18
  production:
19
- database: <%= ENV.fetch("SOLID_CACHE_DATABASE", "solid_cache") %>
19
+ database: <%= ENV.fetch("SOLID_CACHE_DATABASE", "solid_cache_mongoid") %>
20
20
  <<: *default
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidCacheMongoid
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_cache_mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donal McBreen
8
8
  - Duvan Hernandez
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-12 00:00:00.000000000 Z
11
+ date: 2026-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -153,13 +153,9 @@ files:
153
153
  - app/models/solid_cache_mongoid/entry/size/moving_average_estimate.rb
154
154
  - app/models/solid_cache_mongoid/record.rb
155
155
  - lib/active_support/cache/solid_cache_mongoid_store.rb
156
- - lib/generators/solid_cache/install/USAGE
157
- - lib/generators/solid_cache/install/install_generator.rb
158
- - lib/generators/solid_cache/install/templates/config/cache.yml.tt
159
- - lib/generators/solid_cache/install/templates/db/cache_schema.rb
160
- - lib/generators/solid_cache/install/templates/db/cache_structure.mysql.sql
161
- - lib/generators/solid_cache/install/templates/db/cache_structure.postgresql.sql
162
- - lib/generators/solid_cache/install/templates/db/cache_structure.sqlite3.sql
156
+ - lib/generators/solid_cache_mongoid/install/USAGE
157
+ - lib/generators/solid_cache_mongoid/install/install_generator.rb
158
+ - lib/generators/solid_cache_mongoid/install/templates/config/cache.yml.tt
163
159
  - lib/solid_cache_mongoid.rb
164
160
  - lib/solid_cache_mongoid/configuration.rb
165
161
  - lib/solid_cache_mongoid/connections.rb
@@ -1,12 +0,0 @@
1
- ActiveRecord::Schema[7.2].define(version: 1) do
2
- create_table "solid_cache_entries", force: :cascade do |t|
3
- t.binary "key", limit: 1024, null: false
4
- t.binary "value", limit: 536870912, null: false
5
- t.datetime "created_at", null: false
6
- t.integer "key_hash", limit: 8, null: false
7
- t.integer "byte_size", limit: 4, null: false
8
- t.index ["byte_size"], name: "index_solid_cache_entries_on_byte_size"
9
- t.index ["key_hash", "byte_size"], name: "index_solid_cache_entries_on_key_hash_and_byte_size"
10
- t.index ["key_hash"], name: "index_solid_cache_entries_on_key_hash", unique: true
11
- end
12
- end
@@ -1,56 +0,0 @@
1
-
2
- /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
3
- /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
4
- /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
5
- /*!50503 SET NAMES utf8mb4 */;
6
- /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
7
- /*!40103 SET TIME_ZONE='+00:00' */;
8
- /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
9
- /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
10
- /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
11
- /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
12
- DROP TABLE IF EXISTS `ar_internal_metadata`;
13
- /*!40101 SET @saved_cs_client = @@character_set_client */;
14
- /*!50503 SET character_set_client = utf8mb4 */;
15
- CREATE TABLE `ar_internal_metadata` (
16
- `key` varchar(255) NOT NULL,
17
- `value` varchar(255) DEFAULT NULL,
18
- `created_at` datetime(6) NOT NULL,
19
- `updated_at` datetime(6) NOT NULL,
20
- PRIMARY KEY (`key`)
21
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
22
- /*!40101 SET character_set_client = @saved_cs_client */;
23
- DROP TABLE IF EXISTS `schema_migrations`;
24
- /*!40101 SET @saved_cs_client = @@character_set_client */;
25
- /*!50503 SET character_set_client = utf8mb4 */;
26
- CREATE TABLE `schema_migrations` (
27
- `version` varchar(255) NOT NULL,
28
- PRIMARY KEY (`version`)
29
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
30
- /*!40101 SET character_set_client = @saved_cs_client */;
31
- DROP TABLE IF EXISTS `solid_cache_entries`;
32
- /*!40101 SET @saved_cs_client = @@character_set_client */;
33
- /*!50503 SET character_set_client = utf8mb4 */;
34
- CREATE TABLE `solid_cache_entries` (
35
- `id` bigint NOT NULL AUTO_INCREMENT,
36
- `key` varbinary(1024) NOT NULL,
37
- `value` longblob NOT NULL,
38
- `created_at` datetime(6) NOT NULL,
39
- `key_hash` bigint NOT NULL,
40
- `byte_size` int NOT NULL,
41
- PRIMARY KEY (`id`),
42
- UNIQUE KEY `index_solid_cache_entries_on_key_hash` (`key_hash`),
43
- KEY `index_solid_cache_entries_on_byte_size` (`byte_size`),
44
- KEY `index_solid_cache_entries_on_key_hash_and_byte_size` (`key_hash`,`byte_size`)
45
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
46
- /*!40101 SET character_set_client = @saved_cs_client */;
47
- /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
48
-
49
- /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
50
- /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
51
- /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
52
- /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
53
- /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
54
- /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
55
- /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
56
-
@@ -1,128 +0,0 @@
1
- SET statement_timeout = 0;
2
- SET lock_timeout = 0;
3
- SET idle_in_transaction_session_timeout = 0;
4
- SET transaction_timeout = 0;
5
- SET client_encoding = 'UTF8';
6
- SET standard_conforming_strings = on;
7
- SELECT pg_catalog.set_config('search_path', '', false);
8
- SET check_function_bodies = false;
9
- SET xmloption = content;
10
- SET client_min_messages = warning;
11
- SET row_security = off;
12
-
13
- SET default_tablespace = '';
14
-
15
- SET default_table_access_method = heap;
16
-
17
- --
18
- -- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: -
19
- --
20
-
21
- CREATE TABLE public.ar_internal_metadata (
22
- key character varying NOT NULL,
23
- value character varying,
24
- created_at timestamp(6) without time zone NOT NULL,
25
- updated_at timestamp(6) without time zone NOT NULL
26
- );
27
-
28
-
29
- --
30
- -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -
31
- --
32
-
33
- CREATE TABLE public.schema_migrations (
34
- version character varying NOT NULL
35
- );
36
-
37
-
38
- --
39
- -- Name: solid_cache_entries; Type: TABLE; Schema: public; Owner: -
40
- --
41
-
42
- CREATE TABLE public.solid_cache_entries (
43
- id bigint NOT NULL,
44
- key bytea NOT NULL,
45
- value bytea NOT NULL,
46
- created_at timestamp(6) without time zone NOT NULL,
47
- key_hash bigint NOT NULL,
48
- byte_size integer NOT NULL
49
- );
50
-
51
-
52
- --
53
- -- Name: solid_cache_entries_id_seq; Type: SEQUENCE; Schema: public; Owner: -
54
- --
55
-
56
- CREATE SEQUENCE public.solid_cache_entries_id_seq
57
- START WITH 1
58
- INCREMENT BY 1
59
- NO MINVALUE
60
- NO MAXVALUE
61
- CACHE 1;
62
-
63
-
64
- --
65
- -- Name: solid_cache_entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
66
- --
67
-
68
- ALTER SEQUENCE public.solid_cache_entries_id_seq OWNED BY public.solid_cache_entries.id;
69
-
70
-
71
- --
72
- -- Name: solid_cache_entries id; Type: DEFAULT; Schema: public; Owner: -
73
- --
74
-
75
- ALTER TABLE ONLY public.solid_cache_entries ALTER COLUMN id SET DEFAULT nextval('public.solid_cache_entries_id_seq'::regclass);
76
-
77
-
78
- --
79
- -- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: -
80
- --
81
-
82
- ALTER TABLE ONLY public.ar_internal_metadata
83
- ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
84
-
85
-
86
- --
87
- -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
88
- --
89
-
90
- ALTER TABLE ONLY public.schema_migrations
91
- ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
92
-
93
-
94
- --
95
- -- Name: solid_cache_entries solid_cache_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: -
96
- --
97
-
98
- ALTER TABLE ONLY public.solid_cache_entries
99
- ADD CONSTRAINT solid_cache_entries_pkey PRIMARY KEY (id);
100
-
101
-
102
- --
103
- -- Name: index_solid_cache_entries_on_byte_size; Type: INDEX; Schema: public; Owner: -
104
- --
105
-
106
- CREATE INDEX index_solid_cache_entries_on_byte_size ON public.solid_cache_entries USING btree (byte_size);
107
-
108
-
109
- --
110
- -- Name: index_solid_cache_entries_on_key_hash; Type: INDEX; Schema: public; Owner: -
111
- --
112
-
113
- CREATE UNIQUE INDEX index_solid_cache_entries_on_key_hash ON public.solid_cache_entries USING btree (key_hash);
114
-
115
-
116
- --
117
- -- Name: index_solid_cache_entries_on_key_hash_and_byte_size; Type: INDEX; Schema: public; Owner: -
118
- --
119
-
120
- CREATE INDEX index_solid_cache_entries_on_key_hash_and_byte_size ON public.solid_cache_entries USING btree (key_hash, byte_size);
121
-
122
-
123
- --
124
- -- PostgreSQL database dump complete
125
- --
126
-
127
- SET search_path TO "$user", public;
128
-
@@ -1,6 +0,0 @@
1
- CREATE TABLE IF NOT EXISTS "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY);
2
- CREATE TABLE IF NOT EXISTS "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL);
3
- CREATE TABLE IF NOT EXISTS "solid_cache_entries" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "key" blob(1024) NOT NULL, "value" blob(536870912) NOT NULL, "created_at" datetime(6) NOT NULL, "key_hash" integer(8) NOT NULL, "byte_size" integer(4) NOT NULL);
4
- CREATE INDEX "index_solid_cache_entries_on_byte_size" ON "solid_cache_entries" ("byte_size");
5
- CREATE INDEX "index_solid_cache_entries_on_key_hash_and_byte_size" ON "solid_cache_entries" ("key_hash", "byte_size");
6
- CREATE UNIQUE INDEX "index_solid_cache_entries_on_key_hash" ON "solid_cache_entries" ("key_hash");