storj/satellite/accounting
Jessica Grebenschikov 4a2c66fa06 satellite/accounting: add cache for getting project storage and bw limits
This PR adds the following items:
1) an in-memory read-only cache thats stores project limit info for projectIDs

This cache is stored in-memory since this is expected to be a small amount of data. In this implementation we are only storing in the cache projects that have been accessed. Currently for the largest Satellite (eu-west) there is about 4500 total projects. So storing the storage limit (int64) and the bandwidth limit (int64), this would end up being about 200kb (including the 32 byte project ID) if all 4500 projectIDs were in the cache. So this all fits in memory for the time being. At some point it may not as usage grows, but that seems years out.

The cache is a read only cache. When requests come in to upload/download a file, we will read from the cache what the current limits are for that project. If the cache does not contain the projectID, it will get the info from the database (satellitedb project table), then add it to the cache.

The only time the values in the cache are modified is when either a) the project ID is not in the cache, or b) the item in the cache has expired (default 10mins), then the data gets refreshed out of the database. This occurs by default every 10 mins. This means that if we update the usage limits in the database, that change might not show up in the cache for 10 mins which mean it will not be reflected to limit end users uploading/downloading files for that time period..

Change-Id: I3fd7056cf963676009834fcbcf9c4a0922ca4a8f
2020-09-25 16:28:49 +00:00
..
live all: add missing dots 2020-08-11 17:50:01 +03:00
projectbwcleanup satellite/accounting: fix build - time rounding 2020-08-31 09:37:13 -04:00
reportedrollup satellite/orders: use metabase types as arguments 2020-08-28 15:52:37 +03:00
rollup satellite: fix scoping, formatting 2020-07-16 19:13:14 +03:00
tally satellite/metainfo: replace ScopedPath with metabase.SegmentLocation 2020-09-04 10:06:52 +00:00
billing_test.go satellite/metainfo: use metabase.SegmentKey with metainfo.Service 2020-09-03 15:11:32 +00:00
bucketstats.go satellite/metainfo: use metabase in loop 2020-09-01 10:06:16 +00:00
bucketusage.go all: fix dots 2020-07-16 14:58:28 +00:00
common.go all: add missing dots 2020-08-11 17:50:01 +03:00
db_test.go satellite: make limits be nullable 2020-09-21 19:34:19 +00:00
db.go satellite/accounting: add cache for getting project storage and bw limits 2020-09-25 16:28:49 +00:00
projectlimitcache_test.go satellite/accounting: add cache for getting project storage and bw limits 2020-09-25 16:28:49 +00:00
projectlimitcache.go satellite/accounting: add cache for getting project storage and bw limits 2020-09-25 16:28:49 +00:00
projectusage_test.go satellite/accounting: add cache for getting project storage and bw limits 2020-09-25 16:28:49 +00:00
projectusage.go satellite/accounting: add cache for getting project storage and bw limits 2020-09-25 16:28:49 +00:00