https://github.com/superfly/litefs-ruby
Ruby library for interacting with LiteFS.
https://github.com/superfly/litefs-ruby
Last synced: 3 months ago
JSON representation
Ruby library for interacting with LiteFS.
- Host: GitHub
- URL: https://github.com/superfly/litefs-ruby
- Owner: superfly
- Created: 2023-06-03T13:52:41.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-28T08:57:27.000Z (over 1 year ago)
- Last Synced: 2025-03-07T01:18:45.304Z (3 months ago)
- Language: Makefile
- Size: 5.86 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
LiteFS Ruby Library
=================This Ruby library is for interacting with LiteFS features that cannot be accessed
through the typical SQLite API.## Halting
LiteFS provides the ability to halt writes on the primary node in order that
replicas may execute writes remotely and forward them back to the primary. This
isn't necessary in most usage, however, it can make running migrations simpler.Write forwarding from the replica is much slower than executing the write
transaction directly on the primary so only use this for migrations or low-write
scenarios.```ruby
// Execute a write transaction from any node.
// If this is a replica, it will run the inner function with the HALT lock.
user = LiteFS.with_halt do
User.create(name: "David", occupation: "Code Artist")
end
````with_halt` accepts a single, optional, argument specifying the path to the sqlite3 database. If not specified, it will default to the ActiveRecord database if ActiveRecord is used, otherwise to the value of the DATABASE_URL environment variable.