freeze_datasets.rb

lib/sequel/extensions/freeze_datasets.rb
Last Update: 2016-12-21 14:50:31 -0800

The freeze_datasets extension freezes a databases's datasets by default, and makes it so the databases's datasets are always frozen. This makes sure you can never accidentally modify a dataset that may be used elsewhere (such as a model class's dataset or the same dataset being used in another thread). Frozen datasets can also perform caching for many different methods that can significantly improve performance.

In addition to the caching provided by frozen datasets, this also adds caching of Database#from calls if the method is called with a single Symbol argument and not a block. In addition to speeding up Dataset#from itself, because it returns a cached dataset, all caching done by that dataset can also improve performance.

Usage:

DB.extension(:freeze_datasets)

Related module: Sequel::FreezeDatasets