GCache

A simple gosu implementation of concurrent LRU Map.

License

License

GroupId

GroupId

xyz.ronella.gosu
ArtifactId

ArtifactId

gcache
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

GCache
A simple gosu implementation of concurrent LRU Map.
Project URL

Project URL

https://github.com/rcw3bb/gcache
Source Code Management

Source Code Management

https://github.com/rcw3bb/gcache

Download gcache

How to add to project

<!-- https://jarcasting.com/artifacts/xyz.ronella.gosu/gcache/ -->
<dependency>
    <groupId>xyz.ronella.gosu</groupId>
    <artifactId>gcache</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/xyz.ronella.gosu/gcache/
implementation 'xyz.ronella.gosu:gcache:1.1.0'
// https://jarcasting.com/artifacts/xyz.ronella.gosu/gcache/
implementation ("xyz.ronella.gosu:gcache:1.1.0")
'xyz.ronella.gosu:gcache:jar:1.1.0'
<dependency org="xyz.ronella.gosu" name="gcache" rev="1.1.0">
  <artifact name="gcache" type="jar" />
</dependency>
@Grapes(
@Grab(group='xyz.ronella.gosu', module='gcache', version='1.1.0')
)
libraryDependencies += "xyz.ronella.gosu" % "gcache" % "1.1.0"
[xyz.ronella.gosu/gcache "1.1.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.gosu-lang.gosu : gosu-core jar 1.14.14

test (1)

Group / Artifact Type Version
org.gosu-lang.gosu : gosu-test jar 1.14.14

Project Modules

There are no modules declared in this project.

GCache

A simple gosu implementation of concurrent LRU Map.

Public Constructors

Constructors
ConcurrentLRUCache<TYPE_KEY, TYPE_VALUE>(code : String, maxSize : int, evictLogic : BiConsumer<String, Map.Entry<TYPE_KEY, TYPE_VALUE>>)
ConcurrentLRUCache<TYPE_KEY, TYPE_VALUE>(code : String, maxSize : int, losslessLogic : ILosslessLogic<TYPE_KEY, TYPE_VALUE>)
ConcurrentLRUCache<TYPE_KEY, TYPE_VALUE>(code : String, maxSize : int)
ConcurrentLRUCache<TYPE_KEY, TYPE_VALUE>(maxSize : int, evictLogic : BiConsumer<String,Map.Entry<TYPE_KEY, TYPE_VALUE>>)
ConcurrentLRUCache<TYPE_KEY, TYPE_VALUE>(maxSize : int)

Constructor Parameters

Parameter Type Default Description
code String default The code that groups the Map.Entry.
maxSize int The maximum key count of a particular code group in memory. Anything beyond this limit will trigger either the evictLogic or the losslessLogic.
evictLogic BiConsumer<String, Map.Entry<TYPE_KEY, TYPE_VALUE>> A custom eviction logic.
losslessLogic ILosslessLogic<TYPE_KEY, TYPE_VALUE> DefaultLosslessLogic<TYPE_KEY, TYPE_VALUE> An implementation of ILosslessLogic.

Proprietary Methods

Method Description
public function memCacheSize() : int Returns the size of cache in memory.
public function memCachedKeys() : Set<TYPE_KEY> Returns the keys in memory.
public function memCachedValues() : Collection<TYPE_VALUE> Returns the values in memory.

DefaultLosslessLogic<TYPE_KEY, TYPE_VALUE> Class

An implementation of ILosslessLogic<TYPE_KEY, TYPE_VALUE> that only accepts String as the key and Value that must be tag as Serializable. The work of this class will only start if the maxSize key allocated for memory storage was exceeded. If the key counts is beyond the maxSize indicated, all the key entries that are not used will be serialized to the location defined by the environment variable GCACHE_DIR or if it is not present to your <TMP_DIR>\gcache directory. The extension name of a serialized objects is ser.

Usage

  1. Add the following maven dependency to your gosu project:

    Property Value
    Group ID xyz.ronella.gosu
    Artifact ID gcache
    Version 1.1.0

    Using gradle, this can be added as a dependency entry like the following:

    compile group: 'xyz.ronella.gosu', name: 'gcache', version: '1.1.0'
  2. On your code, once an instance of ConcurrentLRUCache was created, use it like you are using an instance of a Map.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Build

Changelog

Author

  • Ronaldo Webb

Versions

Version
1.1.0
1.0.1
1.0.0