mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Various
This commit is contained in:
parent
2df77f89e9
commit
2f67f427f2
@ -15,8 +15,10 @@ You can check [my own Maloja page](https://maloja.krateng.ch) to see what it loo
|
||||
## Table of Contents
|
||||
* [Why not Last.fm / Libre.fm / GNU FM?](#why-not-lastfm--librefm--gnu-fm)
|
||||
* [How to install](#how-to-install)
|
||||
* [Environment](#environment)
|
||||
* [New Installation](#new-installation)
|
||||
* [Update](#update)
|
||||
* [Docker](#docker)
|
||||
* [How to use](#how-to-use)
|
||||
* [Basic control](#basic-control)
|
||||
* [Data](#data)
|
||||
@ -40,6 +42,10 @@ Also neat: You can use your **custom artist or track images**.
|
||||
|
||||
## How to install
|
||||
|
||||
### Environment
|
||||
|
||||
I can support you with issues best if you use **Alpine Linux**. In my experience, **2-4 GB RAM** should do nicely.
|
||||
|
||||
### New Installation
|
||||
|
||||
1) Make sure you have Python 3.5 or higher installed. You also need some basic packages that should be present on most systems, but I've provided simple shell scripts for Alpine and Ubuntu to get everything you need.
|
||||
|
@ -59,7 +59,7 @@ SCROBBLES_GOLD = 250
|
||||
SCROBBLES_PLATINUM = 500
|
||||
SCROBBLES_DIAMOND = 1000
|
||||
# name for comparisons
|
||||
NAME = None
|
||||
NAME = "A Maloja User"
|
||||
|
||||
[Misc]
|
||||
|
||||
|
@ -1126,10 +1126,7 @@ def db_query_cached(**kwargs):
|
||||
elif eligible_temporary_caching: cache_query[key] = result
|
||||
|
||||
if use_psutil:
|
||||
ramprct = psutil.virtual_memory().percent
|
||||
if ramprct > cmp:
|
||||
log("{prct} RAM usage, dumping temporary caches!".format(prct=ramprct),module="debug")
|
||||
invalidate_caches()
|
||||
reduce_caches_if_low_ram()
|
||||
|
||||
return result
|
||||
|
||||
@ -1165,10 +1162,7 @@ def db_aggregate_cached(**kwargs):
|
||||
elif eligible_temporary_caching: cache_aggregate[key] = result
|
||||
|
||||
if use_psutil:
|
||||
ramprct = psutil.virtual_memory().percent
|
||||
if ramprct > cmp:
|
||||
log("{prct} RAM usage, dumping temporary caches!".format(prct=ramprct),module="debug")
|
||||
invalidate_caches()
|
||||
reduce_caches_if_low_ram()
|
||||
|
||||
return result
|
||||
|
||||
@ -1178,6 +1172,21 @@ def invalidate_caches():
|
||||
cache_aggregate.clear()
|
||||
log("Database caches invalidated.")
|
||||
|
||||
def reduce_caches(to=0.75):
|
||||
global cache_query, cache_aggregate
|
||||
for c in cache_query, cache_aggregate:
|
||||
currentsize = len(c)
|
||||
targetsize = int(currentsize * to)
|
||||
c.set_size(targetsize)
|
||||
c.set_size(csz)
|
||||
|
||||
def reduce_caches_if_low_ram():
|
||||
ramprct = psutil.virtual_memory().percent
|
||||
if ramprct > cmp:
|
||||
log("{prct}% RAM usage, reducing temporary caches!".format(prct=ramprct),module="debug")
|
||||
ratio = (cmp / ramprct) ** 3
|
||||
reduce_caches(to=ratio)
|
||||
|
||||
####
|
||||
## Database queries
|
||||
####
|
||||
|
Loading…
Reference in New Issue
Block a user