Module | Sequel::Plugins::StaticCache::ClassMethods
In: | lib/sequel/plugins/static_cache.rb

### Methods

all cache_get_pk each map set_dataset to_hash

### Attributes

cache | [R] | A frozen ruby hash holding all of the model‘s frozen instances, keyed by frozen primary key.

### Public Instance methods

all()

An array of all of the model‘s frozen instances, without issuing a database query.

[Source]

        # File lib/sequel/plugins/static_cache.rb, line 34
    34:         def all
    35:           @all.dup
    36:         end

cache_get_pk(pk)

Return the frozen object with the given pk, or nil if no such object exists in the cache, without issuing a database query.

[Source]

        # File lib/sequel/plugins/static_cache.rb, line 40
    40:         def cache_get_pk(pk)
    41:           cache[pk]
    42:         end

each(&block)

Yield each of the model‘s frozen instances to the block, without issuing a database query.

[Source]

        # File lib/sequel/plugins/static_cache.rb, line 46
    46:         def each(&block)
    47:           @all.each(&block)
    48:         end

map(*a)

If no arguments are given, yield each of the model‘s frozen instances to the block. and return a new array, without issuing a database query. If any arguments are given, use the default Sequel behavior.

[Source]

        # File lib/sequel/plugins/static_cache.rb, line 53
    53:         def map(*a)
    54:           if a.empty?
    55:             @all.map(&(Proc.new if block_given?))
    56:           else
    57:             super
    58:           end
    59:         end

set_dataset(*)

Reload the cache when the dataset changes.

[Source]

        # File lib/sequel/plugins/static_cache.rb, line 62
    62:         def set_dataset(*)
    63:           s = super
    64:           load_cache
    65:           s
    66:         end

to_hash(*a)

If no arguments are given, yield an identity map for the model with frozen primary keys and instances, without issuing a database query. If any arguments are given, use the default Sequel behavior.

[Source]

        # File lib/sequel/plugins/static_cache.rb, line 71
    71:         def to_hash(*a)
    72:           if a.empty?
    73:             cache.dup
    74:           else
    75:             super
    76:           end
    77:         end

[Validate]