Skip to content

StumbleUponArchive/stumblecache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StumbleCache

Stumblecache is a high performance shared memory cache that scales to tens of gigabytes of cache, thousands of requests per second, and high update rates. It was created to allow Stumbleupon to cache large amounts of short ttl url data on our webserver and worker tiers.

You can think of it as a replacement for the user caching portion of apc, though different tradeoffs have been made and stumblecache will be less space efficient in most cases.

  • MMAP based
  • Fixed allocations ie. 500k 2k cache blocks

API

INI

  • stumblecache.location: the path where all the caches are stored

Class: StumbleCacheOptions


  • nrOfItems is the maximum number of items in the cache.
  • itemSize is the size of each item in the cache.

    rounded up to nearest 4kb (or pagesize)

The cache will use nrOfItems * itemSize amount of memory, plus some overhead.

Class: StumbleCache


  • cacheRef: string: name of the cache

Cache Layout

/tmp/<cache-id>.scstats

/tmp/<cache-id>.scache

page 0: meta-data

  • cache file version: 4 bytes
  • item size: 4 bytes
  • nr of items: 4 bytes
  • next data page: 4 bytes

page 1-x: index, b-tree

  • b-tree node: 1023 keys, 1024 children

    • header:

      • leaf: yes/no byte
      • nrOfKeys: 1-1023 2 bytes
    • keys

      • key: 8 bytes
      • value idx: 4 bytes number = idx into data block
      • expire ts: 2 bytes
      • flags: 2 bytes

        • in use: 1 bit

License

This extension is released under the PHP 3.01 license, see LICENSE file for details

This product includes PHP software, freely available from <http://www.php.net/software/>

About

StumbleCache is a mmap backed caching extension for PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published