Nebulex v1.0.1 Nebulex.Adapters.Local.Generation View Source
Generations Handler. This GenServer acts as garbage collector, everytime it runs, a new cache generation is created a the oldest one is deleted.
The only way to create new generations is through this module (this
server is the metadata owner) calling new/2 function. When a Cache
is created, a generations handler associated to that Cache is started
at the same time, therefore, this server MUST NOT be started directly.
Options
:gc_interval- Interval time in seconds to garbage collection to run, delete the oldest generation and create a new one. If this option is not set, garbage collection is never executed, so new generations must be created explicitly, e.g.:new(cache, []).
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor
Flushes the cache (including all its generations)
Creates a new cache generation. Once the max number of generations is reached, when a new generation is created, the oldest one is deleted
Link to this section Functions
child_spec(arg) View Source
Returns a specification to start this module under a supervisor.
See Supervisor.
flush(cache)
View Source
flush(Nebulex.Cache.t()) :: :ok
flush(Nebulex.Cache.t()) :: :ok
Flushes the cache (including all its generations).
cache- Cache Module
Example
flush(MyCache)
new(cache, opts \\ [])
View Source
new(Nebulex.Cache.t(), Nebulex.Cache.opts()) :: [atom()]
new(Nebulex.Cache.t(), Nebulex.Cache.opts()) :: [atom()]
Creates a new cache generation. Once the max number of generations is reached, when a new generation is created, the oldest one is deleted
cache- Cache Moduleopts- List of options
Options
:reset_timeout- Indicates if the poll frequency time-out should be reset or not (default: true).
Example
new_generation(MyCache, reset_timeout: :false)