Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
= AsyncRecord
One of the greatest things about running on an event-based server is that you can get accelerated performance in database access.
Usually there is a lot of time spent blocking for a database query to return. In AsyncRecord, your queries don't block the request. You will receive a callback once the query has completed. This has major performance implications.
NOTE: Even though your connections are non-blocking to the database server, the database server is still blocking when accessing IO (disk/memory).
To use AsyncRecord, do the following:
Install the Gem:
sudo gem install async_record
Setup async_record:
require 'async_record' conn = AsyncRecord::Connection::MySQL.new(:host => "127.0.0.1", :port => 3306, :user => "root", :database => "database") conn.connect
Define a model:
class User < AsyncRecord::Base set_table_name "users" end
=== Controller
These examples are for the Fastr web framework.
In your controller, try the following (remember to put the following in a deferred response):
=== Get all the rows in the table:
User.all(:limit => 256) do |users| users.each do |user| response.send_data("#{user.username}\n") end response.succeed end
=== Find a row by ID
User.find(1) do |user| if user.nil? response.send_data("User not found") else response.send_data("User: #{user.username}\n") end response.succeed end
=== Get the count of rows in the table
User.count do |count| response.send_data("Count: #{count}") response.succeed end
=== Run a custom query
User.query("select username from users") do |results| response.send_data("Results: #{results.inspect}") response.succeed end
WARNING: AsyncRecord is under heavy development, but its pretty cool :).
FAQs
Unknown package
We found that async_record demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.