http service: rename kc to chat
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.http.service.kc;
|
||||
package net.runelite.http.service.chat;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
@@ -36,18 +36,18 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/kc")
|
||||
public class KillCountController
|
||||
@RequestMapping("/chat")
|
||||
public class ChatController
|
||||
{
|
||||
private final Cache<KillCountKey, Integer> cache = CacheBuilder.newBuilder()
|
||||
private final Cache<KillCountKey, Integer> killCountCache = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(2, TimeUnit.MINUTES)
|
||||
.maximumSize(128L)
|
||||
.build();
|
||||
|
||||
@Autowired
|
||||
private KillCountService killCountService;
|
||||
private ChatService chatService;
|
||||
|
||||
@PostMapping
|
||||
@PostMapping("/kc")
|
||||
public void submit(@RequestParam String name, @RequestParam String boss, @RequestParam int kc)
|
||||
{
|
||||
if (kc <= 0)
|
||||
@@ -55,20 +55,20 @@ public class KillCountController
|
||||
return;
|
||||
}
|
||||
|
||||
killCountService.setKc(name, boss, kc);
|
||||
cache.put(new KillCountKey(name, boss), kc);
|
||||
chatService.setKc(name, boss, kc);
|
||||
killCountCache.put(new KillCountKey(name, boss), kc);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@GetMapping("/kc")
|
||||
public int get(@RequestParam String name, @RequestParam String boss)
|
||||
{
|
||||
Integer kc = cache.getIfPresent(new KillCountKey(name, boss));
|
||||
Integer kc = killCountCache.getIfPresent(new KillCountKey(name, boss));
|
||||
if (kc == null)
|
||||
{
|
||||
kc = killCountService.getKc(name, boss);
|
||||
kc = chatService.getKc(name, boss);
|
||||
if (kc != null)
|
||||
{
|
||||
cache.put(new KillCountKey(name, boss), kc);
|
||||
killCountCache.put(new KillCountKey(name, boss), kc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.http.service.kc;
|
||||
package net.runelite.http.service.chat;
|
||||
|
||||
import java.time.Duration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -31,14 +31,14 @@ import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
@Service
|
||||
public class KillCountService
|
||||
public class ChatService
|
||||
{
|
||||
private static final Duration KC_EXPIRE = Duration.ofMinutes(2);
|
||||
private static final Duration EXPIRE = Duration.ofMinutes(2);
|
||||
|
||||
private final JedisPool jedisPool;
|
||||
|
||||
@Autowired
|
||||
public KillCountService(JedisPool jedisPool)
|
||||
public ChatService(JedisPool jedisPool)
|
||||
{
|
||||
this.jedisPool = jedisPool;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class KillCountService
|
||||
{
|
||||
try (Jedis jedis = jedisPool.getResource())
|
||||
{
|
||||
jedis.setex("kc." + name + "." + boss, (int) KC_EXPIRE.getSeconds(), Integer.toString(kc));
|
||||
jedis.setex("kc." + name + "." + boss, (int) EXPIRE.getSeconds(), Integer.toString(kc));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.http.service.kc;
|
||||
package net.runelite.http.service.chat;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
Reference in New Issue
Block a user