Giter Site home page Giter Site logo

stumblecache's Introduction

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

__construct( nrOfItems, itemSize )

  • 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

__construct ( cacheRef )

  • 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/>

stumblecache's People

Contributors

auroraeosrose avatar derickr avatar jeichorn avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.