Module: Mongoid::AutoIncrementId

Defined in:
lib/mongoid/auto_increment_id/config.rb,
lib/mongoid/auto_increment_id/version.rb

Constant Summary collapse

VERSION =
'0.8.1'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cache_storeObject

ActiveSupport::Cache::Store default: ActiveSupport::Cache.lookup_store(:memory_store)

Mongoid::AutoIncrementId.cache_store = ActiveSupport::Cache.lookup_store(:memcache_store, “127.0.0.1”) For cache ids



21
22
23
# File 'lib/mongoid/auto_increment_id/config.rb', line 21

def cache_store
  @cache_store
end

.seq_cache_sizeObject

How many ids generate in once call, and it will cache ids in Memroy, to reduce MongoDB write default: 1

Call first

-> [occupancy N and Write MongoDB] -> [Save N ids in Memory variable ‘aii_cache`]

Next call

-> [Shift aii_cache and return]

.….

N+1 call

-> [occupancy N and Write MongoDB] -> [Save N ids in Memory variable ‘aii_cache`]



14
15
16
# File 'lib/mongoid/auto_increment_id/config.rb', line 14

def seq_cache_size
  @seq_cache_size
end

Class Method Details

.cache_enabled?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/mongoid/auto_increment_id/config.rb', line 23

def cache_enabled?
  self.seq_cache_size > 1
end