Skip to content

A MemoryCache which tries to prevent cache miss for hot entries, by refreshing before expiration.

Notifications You must be signed in to change notification settings

AmirRaptoR/Auto-Refreshing-Cache

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

AutoRefreshingCache is a MemoryCache which tries to refresh its hot entries before their actual expiration time is reached.
This class gives you a single public method (i.e. GET).
Here comes the pseudocode.


get(param)
	result = cache.get(param)
	if (result == null)
		refresh(param, null)
		return cache.get(param)
	if (result needs to be refreshed)
		result.refreshWorkers.increment
		if (result.refreshWorkers == 1)
			run refresh(param, res.refreshWorkers) in a new thread
	return res.data


refresh(param, refreshWorkers)
	data = calc(param)
	cache.add(key:param, value:data, expiration:exp_time)
	if (refreshWorkers != null)
		refreshWorkers.decrement

About

A MemoryCache which tries to prevent cache miss for hot entries, by refreshing before expiration.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%