OC.L10N.register( "files_external", { "External storages" : "Almacenamientos internos", "Personal" : "Personal", "System" : "Sistema", "Grant access" : "Conceder accesu", "Error configuring OAuth1" : "Fallu configurando Oauth1", "Error configuring OAuth2" : "Fallu configurando OAuth2", "Generate keys" : "Xenerar claves", "Error generating key pair" : "Fallu xenerando'l par de claves", "All users. Type to select user or group." : "Tolos usuarios. Escribe pa seleccionar usuariu o grupu.", "(group)" : "(grupu)", "Delete storage?" : "¿Desaniciar almacenamientu?", "Saved" : "Guardáu", "Saving..." : "Guardando...", "Save" : "Guardar", "Empty response from the server" : "Rempuesta balera del sirvidor", "Couldn't access. Please log out and in again to activate this mount point" : "Nun pudo accedese. Volvi aniciar sesión p'activar esti puntu de montaxe, por favor", "Couldn't get the list of external mount points: {type}" : "Nun pudo consiguise'l llistáu de puntos esternos de montaxe: {type}", "There was an error with message: " : "Hebo un fallu col mensaxe:", "External mount error" : "Fallu de montaxe esternu", "Username" : "Nome d'usuariu", "Password" : "Contraseña", "Invalid mount point" : "Puntu de montaxe non válidu", "%s" : "%s", "Secret key" : "Clave secreta", "None" : "Dengún", "OAuth1" : "OAuth1", "App key" : "Clave d'aplicación", "OAuth2" : "OAuth2", "Client ID" : "ID de veceru", "Client secret" : "Veceru secretu", "Domain" : "Dominiu", "API key" : "clave API", "Global credentials" : "Credenciales global", "Username and password" : "Nome d'usuariu y contraseña", "RSA public key" : "Clave RSA pública", "Public key" : "Clave pública", "Amazon S3" : "Amazon S3", "Bucket" : "Depósitu", "Hostname" : "Nome d'agospiu", "Port" : "Puertu", "Region" : "Rexón", "Enable SSL" : "Habilitar SSL", "Enable Path Style" : "Habilitar Estilu de ruta", "WebDAV" : "WebDAV", "URL" : "URL", "Remote subfolder" : "Subcarpeta remota", "Host" : "Sirvidor", "Local" : "Llocal", "Location" : "Llocalización", "Nextcloud" : "Nextcloud", "SFTP" : "SFTP", "Root" : "Raíz", "SMB / CIFS" : "SMB / CIFS", "Share" : "Compartir", "SMB / CIFS using OC login" : "SMB / CIFS usando accesu OC", "Username as share" : "Nome d'usuariu como Compartición", "OpenStack Object Storage" : "OpenStack Object Storage", "Service name" : "Nome del serviciu", "Name" : "Nome", "Storage type" : "Triba d'almacenamientu", "Scope" : "Ámbitu", "Enable encryption" : "Habilitar cifráu", "Never" : "Enxamás", "Folder name" : "Nome de la carpeta", "External storage" : "Almacenamientu esternu", "Authentication" : "Autenticación", "Configuration" : "Configuración", "Available for" : "Disponible pa", "Add storage" : "Amestar almacenamientu", "Advanced settings" : "Axustes avanzaos", "Delete" : "Desaniciar", "Allow users to mount the following external storage" : "Permitir a los usuarios montar el siguiente almacenamientu esternu", "OpenStack" : "OpenStack", "No external storage configured" : "Nun se configuraron almacenamientos esternos", "You can add external storages in the personal settings" : "Pues amestar almacenamientos enternos nos axustes personales" }, "nplurals=2; plural=(n != 1);"); rs Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/lib/private/Cache/CappedMemoryCache.php
blob: 2c2eab3209abdb2d2d27a8e87b4966f19cea8a1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php

/**
 * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
 * SPDX-License-Identifier: AGPL-3.0-only
 */
namespace OC\Cache;

use OCP\ICache;

/**
 * In-memory cache with a capacity limit to keep memory usage in check
 *
 * Uses a simple FIFO expiry mechanism
 * @template T
 * @deprecated use OCP\Cache\CappedMemoryCache instead
 */
class CappedMemoryCache implements ICache, \ArrayAccess {
	private $capacity;
	/** @var T[] */
	private $cache = [];

	public function __construct($capacity = 512) {
		$this->capacity = $capacity;
	}

	public function hasKey($key): bool {
		return isset($this->cache[$key]);
	}

	/**
	 * @return ?T
	 */
	public function get($key) {
		return $this->cache[$key] ?? null;
	}

	/**
	 * @param string $key
	 * @param T $value
	 * @param int $ttl
	 * @return bool
	 */
	public function set($key, $value, $ttl = 0): bool {
		if (is_null($key)) {
			$this->cache[] = $value;
		} else {
			$this->cache[$key] = $value;
		}
		$this->garbageCollect();
		return true;
	}

	public function remove($key) {
		unset($this->cache[$key]);
		return true;
	}

	public function clear($prefix = '') {
		$this->cache = [];
		return true;
	}

	public function offsetExists($offset): bool {
		return $this->hasKey($offset);
	}

	/**
	 * @return T
	 */
	#[\ReturnTypeWillChange]
	public function &offsetGet($offset) {
		return $this->cache[$offset];
	}

	/**
	 * @param string $offset
	 * @param T $value
	 * @return void
	 */
	public function offsetSet($offset, $value): void {
		$this->set($offset, $value);
	}

	public function offsetUnset($offset): void {
		$this->remove($offset);
	}

	/**
	 * @return T[]
	 */
	public function getData() {
		return $this->cache;
	}


	private function garbageCollect() {
		while (count($this->cache) > $this->capacity) {
			reset($this->cache);
			$key = key($this->cache);
			$this->remove($key);
		}
	}

	public static function isAvailable(): bool {
		return true;
	}
}