Skip to content

Commit

Permalink
test with implements partial
Browse files Browse the repository at this point in the history
  • Loading branch information
orbyfied committed Dec 10, 2023
1 parent 3673840 commit 312f5ba
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,24 @@
public class MongoDatastoreExample {

@ToString
public static class Stats {
public static class Stats implements PartialStats {
@Key
protected UUID uuid;

// no support for primitives yet bc im too
// lazy to make that work with Unsafe rn
protected Integer kills = 0;
protected Integer deaths = 0;

@Override
public UUID uuid() {
return uuid;
}

@Override
public Integer deaths() {
return deaths;
}
}

public interface PartialStats {
Expand Down Expand Up @@ -112,7 +122,7 @@ public static void main(String[] args) throws InterruptedException {
.forEach(FoundItem::fetch);

// Randomize cache values
datastore.getDataCache().forEach(item -> item.get().deaths += (int)(Math.random() * 10));
datastore.getDataCache().forEach(item -> item.get().deaths += (int)((Math.random() + 1) * 10));

// Try to get sorted list of items including locally cached values
datastore.findAll(Query.all(), FindAllOperation.Options.builder().useCaches(true).build())
Expand Down

0 comments on commit 312f5ba

Please sign in to comment.