Module: MongoAutoIncrement
- Defined in:
- lib/mongo_auto_increment.rb,
lib/mongo_auto_increment/config.rb,
lib/mongo_auto_increment/version.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.1.1"
Class Attribute Summary collapse
-
.cache_store ⇒ Object
ActiveSupport::Cache::Store default: ActiveSupport::Cache.lookup_store(:memory_store).
-
.seq_cache_size ⇒ Object
How many ids generate in once call, and it will cache ids in Memroy, to reduce MongoDB write default: 1.
Class Method Summary collapse
Class Attribute Details
.cache_store ⇒ Object
ActiveSupport::Cache::Store default: ActiveSupport::Cache.lookup_store(:memory_store)
MongoAutoIncrement.cache_store = ActiveSupport::Cache.lookup_store(:memcache_store, “127.0.0.1”) For cache ids
20 21 22 |
# File 'lib/mongo_auto_increment/config.rb', line 20 def cache_store @cache_store end |
.seq_cache_size ⇒ Object
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]
13 14 15 |
# File 'lib/mongo_auto_increment/config.rb', line 13 def seq_cache_size @seq_cache_size end |
Class Method Details
.cache_enabled? ⇒ Boolean
22 23 24 |
# File 'lib/mongo_auto_increment/config.rb', line 22 def cache_enabled? self.seq_cache_size > 1 end |