package com.red.circle.other.infra.database.cache.service.other.impl;

import com.red.circle.component.redis.service.RedisService;
import com.red.circle.other.infra.database.cache.key.GameListKeys;
import com.red.circle.other.infra.database.cache.service.other.GameTurntableCacheService;
import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 砸金蛋.
 *
 * @author pengshigang on 2021/11/16
 */
@Service
@RequiredArgsConstructor
public class GameTurntableCacheServiceImpl implements GameTurntableCacheService {

  private final RedisService redisService;


  @Override
  public String listTop20(String sysOrigin) {
    return redisService
        .getString(GameListKeys.GAME_TURNTABLE_TOP20.getKey(sysOrigin));
  }

  @Override
  public void pushTop20(String sysOrigin, String data) {
    redisService
        .setIfAbsent(GameListKeys.GAME_TURNTABLE_TOP20.getKey(sysOrigin), data, 1, TimeUnit.DAYS);
  }

}
