Skip to content
/ soc Public

simple object cache. functional, stampede safe, with configurable constructs for expiration.

License

Notifications You must be signed in to change notification settings

shorrockin/soc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SOC – Simple Object Cache

Primary Author Chris Shorrock
Stable Version N/A
Snapshot Version 1.0-SNAPSHOT
Scala Version 2.8.0

Description:

A really simple map cache implementation in scala, which has rule based expiration of elements, functional constructs and cache stampede protection. Very simplistic, use it if you like. Just threw it in github so that I didn’t have to re-implement logic across projects.

Usage:

Usage is quite simple. Create an instance of the cache. Pass in a request to retrieve contents with the function needed to populate on cache expiration.


import com.shorrockin.soc._
val cache = new Soc[String, String](new TimeExpiredRule(60000))

// returns "hello world"
val cached1 = cache.get("cache-key") { "hello world" }

// still returns "hello world"
val cached2 = cache.get("cache-key") { "never gets called" }

// based on the rules provided in the Soc constructor, this dictates 
// that cache elements expire after 60000 msecs.
Thread.sleep(60000)

// will re-execute the function to re-populate the cache, will
// return "hello again world"
val cache3 = cache.get("cache-key") { "hello again world" }

Maven Information


  <dependencies>
    <dependency>
      <groupId>com.shorrockin</groupId>
      <artifactId>soc</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>
  </dependencies>

  <repositories>
    <repository>
      <id>shorrockin.com</id>
      <name>Shorrockin Repository</name>
      <url>http://maven.shorrockin.com/</url>
    </repository>
  </repositories>

About

simple object cache. functional, stampede safe, with configurable constructs for expiration.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages