Modified App Engine Sharded Counters Library
Python
Pull request Compare This branch is 4 commits ahead of GoogleCloudPlatform:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.md
general_counter.py

README.md

Sharded Counters Library for App Engine

A revision of the original sharding counters example library from Google (https://github.com/GoogleCloudPlatform/appengine-sharded-counters-python).

This fork adds:

  • A reset method to set all the counters to zero.

  • A delta parameter to increase the counter by any number (not just by 1), including negative values (the equivalent to decrement).

  • A small refactor that encapsulates all the available methods to its related model (for portability).

The original provides:

  • Simple Sharding: Uses a constant to define the number of shards and randomly picks an index up to this number when incrementing the counter. Each shard is stored in the datastore using one of these indices as ID.

  • General Sharding: Stores the number of shards in the datastore and randomly picks an index up to this number when incrementing the counter. Each shard is stored in the datastore using one of these indices as ID, but also using a counter name as an ancestor.

Products

Language

APIs

Dependencies