https://github.com/akifev/player-storage
Library for managing the storage of players.
https://github.com/akifev/player-storage
java kotlin library
Last synced: 2 months ago
JSON representation
Library for managing the storage of players.
- Host: GitHub
- URL: https://github.com/akifev/player-storage
- Owner: akifev
- Created: 2020-03-20T00:16:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-06-20T22:45:25.000Z (about 4 years ago)
- Last Synced: 2025-12-27T17:31:08.918Z (6 months ago)
- Topics: java, kotlin, library
- Language: Kotlin
- Homepage: https://akifev.github.io/player-storage
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Player Storage
[](https://jitpack.io/#akifev/player-storage)
This is a library for managing the storage of players with the ability
to add or update, delete, get a rank, and roll back.
## Table Of Contents
* [Overview](#overview)
* [Operations](#operations)
* [Using in your project](#using-in-your-project)
* [Maven](#maven)
* [Gradle](#gradle)
* [Performance](#performance)
* [JMH Benchmark](#jmh-benchmark)
## Overview
This library contains the thread-safe class PlayerStorage which implements Storage interface.
### Operations
Class PlayerStorage implements the following methods.
#### registerPlayerResult
Adds a player with a rating or updates a player rating, if one has been already added.
```kotlin
@Synchronized
fun registerPlayerResult(playerName: String, playerRating: Int): Boolean
```
**Note:** This method is marked as @Synchronized.
#### unregisterPlayer
Deletes the player from the storage.
```kotlin
@Synchronized
fun unregisterPlayer(playerName: String): Boolean
```
**Note:** This method is marked as @Synchronized.
#### getPlayerRank
Returns player rank. Rank is a position in the rating table.
```kotlin
fun getPlayerRank(playerName: String): Int?
```
#### rollback
Rolls the last [step] registerPlayerResult or unregisterPlayer invocations back.
```kotlin
@Synchronized
fun rollback(step: Int): Boolean
```
**Note:** This method is marked as @Synchronized.
## Using in your project
The library published to JitPack repository.
### Maven
Step 1. Add the JitPack repository to your build file.
```xml
jitpack.io
https://jitpack.io
```
Step 2. Add the dependency.
```xml
com.github.akifev
player-storage
2.0
```
### Gradle
Step 1. Add the JitPack repository to your build file.
```groovy
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
Step 2. Add the dependency.
```groovy
dependencies {
implementation 'com.github.akifev:player-storage:2.0'
}
```
## Performance
### JMH Benchmark
Here is the relation of average operation execution time to the quantity of players added to the storage.
|Quantity of players | 14 | 62 | 1022 | 8190 | 65534 | |
|:-------------------|:-----:|:-----:|:-----:|:-----:|:-----:|--------:|
|registerPlayerResult|307 |510 |1079 |1984 |4156 |ns/op |
|unregisterPlayer |313 |585 |1123 |1974 |4385 |ns/op |
|getPlayerRank |135 |239 |544 |1104 |2328 |ns/op |
|rollback |58 |50 |59 |31 |9 |ns/op |