storj/satellite/satellitedb
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
..
dbx satellite/accounting: add cache for getting project storage and bw limits 2020-09-25 16:28:49 +00:00
satellitedbtest all: fix dots 2020-07-16 14:58:28 +00:00
testdata satellite/satellitedb: enable multiple projects existing users 2020-09-23 18:17:38 +02:00
apikeys.go all: fix dots 2020-07-16 14:58:28 +00:00
attribution_test.go all: remove old uuid 2020-04-02 19:30:36 +03:00
attribution.go all: fix dots 2020-07-16 14:58:28 +00:00
audithistory_test.go satellite/{overlay,satellitedb}: Create database functionality for updating audit history 2020-08-20 17:34:27 +00:00
audithistory.go satellite/{overlay,satellitedb}: Create database functionality for updating audit history 2020-08-20 17:34:27 +00:00
buckets.go satellite/orders: add bucket id to order limit 2020-09-03 10:50:11 +03:00
coinpaymentstxs_test.go satellite/satellitedb: Coinpayments repeat insert bug fix 2020-07-20 20:21:35 +00:00
coinpaymentstxs.go satellite/satellitedb: Coinpayments repeat insert bug fix 2020-07-20 20:21:35 +00:00
compensation.go all: fix dots 2020-07-16 14:58:28 +00:00
consoledb_test.go satellite/satellitedb/satellitedbtest: pass ctx as an argument 2020-01-20 16:35:42 +02:00
consoledb.go satellite/payments: fix promotional coupons 2020-01-29 16:40:43 +02:00
containment.go all: fix dots 2020-07-16 14:58:28 +00:00
coupons.go all: fix dots 2020-07-16 14:58:28 +00:00
customers.go all: replace == comparison with errors.Is 2020-07-14 15:50:25 +00:00
database.go storagenode: heldamount renamed to payouts, renamed some methods and structs to more meaningful names. grouped estimated payout with pathouts 2020-09-16 14:57:35 +00:00
downtime.go satellite/satellitedb/dbx: name the package dbx 2020-01-15 15:16:39 -07:00
gracefulexit.go satellite/gracefulexit: replace Path []byte to `Key 2020-09-04 11:09:48 +00:00
invoiceprojectrecords.go satellite/payments: delete credits and credits_spendings db tables 2020-07-30 12:19:57 +03:00
irreparabledb.go satellite/repair: use metabase.SegmentKey type in repair package 2020-09-08 19:35:20 +00:00
migrate_test.go all: fix comments 2020-07-16 19:13:14 +03:00
migrate.go satellite/satellitedb: enable multiple projects existing users 2020-09-23 18:17:38 +02:00
nodeapiversion.go all: use jackc/pgx in place of lib/pq 2020-07-13 15:54:41 +00:00
nodeselection.go satellite/satellitedb: uses vetted_at field to select for reputable nodes 2020-09-04 16:45:32 +00:00
offers.go all: add missing dots 2020-08-11 17:50:01 +03:00
orders.go all: add missing dots 2020-08-11 17:50:01 +03:00
overlaycache_test.go satellite/satellitedb: uses vetted_at field to select for reputable nodes 2020-09-04 16:45:32 +00:00
overlaycache.go satellite/satellitedb: uses vetted_at field to select for reputable nodes 2020-09-04 16:45:32 +00:00
payout.go storagenode: heldamount renamed to payouts, renamed some methods and structs to more meaningful names. grouped estimated payout with pathouts 2020-09-16 14:57:35 +00:00
peeridentities.go all: fix dots 2020-07-16 14:58:28 +00:00
projectaccounting.go satellite/accounting: add cache for getting project storage and bw limits 2020-09-25 16:28:49 +00:00
projectmembers_test.go web/satellite: project members sorting fixed (#3231) 2019-10-15 15:24:53 +03:00
projectmembers.go all: fix dots 2020-07-16 14:58:28 +00:00
projects_test.go satellite/satellitedb/dbx: name the package dbx 2020-01-15 15:16:39 -07:00
projects.go satellite: make limits be nullable 2020-09-21 19:34:19 +00:00
regtokens.go all: fix dots 2020-07-16 14:58:28 +00:00
repairqueue.go satellite/satellitedb: add column and index "updated_at" to injuredsegments 2020-09-14 12:53:04 -04:00
resetpasstokens.go all: fix dots 2020-07-16 14:58:28 +00:00
revocation_test.go satellite: Check macaroon revocation 2020-06-22 13:50:07 -06:00
revocation.go all: fix dots 2020-07-16 14:58:28 +00:00
storagenodeaccounting.go satellite/storageusage: Group accounting rollups at_rest_total by day 2020-08-10 15:03:15 +00:00
stripecoinpaymentsdb.go satellite/payments: delete credits and credits_spendings db tables 2020-07-30 12:19:57 +03:00
usercredits.go all: fix dots 2020-07-16 14:58:28 +00:00
users_test.go satellite/satellitedb/dbx: name the package dbx 2020-01-15 15:16:39 -07:00
users.go all: fix dots 2020-07-16 14:58:28 +00:00