초기커밋
This commit is contained in:
118
ServerCommon/Cache/LandAuctionBidPriceOrderCacheRequest.cs
Normal file
118
ServerCommon/Cache/LandAuctionBidPriceOrderCacheRequest.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using StackExchange.Redis;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class LandAuctionTopBidderCache : CacheBase
|
||||
{
|
||||
public META_ID LandMetaId { get; set; } = 0;
|
||||
public USER_GUID HighestBidUserGuid { get; set; } = string.Empty;
|
||||
public double HighestBidPrice { get; set; } = 0;
|
||||
|
||||
public LandAuctionTopBidderCache()
|
||||
{ }
|
||||
}
|
||||
|
||||
|
||||
public class LandAuctionBidPriceOrderCacheRequest : RedisRequestSharedBase
|
||||
{
|
||||
private readonly META_ID m_land_meta_id;
|
||||
|
||||
public LandAuctionBidPriceOrderCacheRequest(META_ID landMetaId, RedisConnector redisConnector)
|
||||
: base(landMetaId.ToString(), redisConnector)
|
||||
{
|
||||
m_land_meta_id = landMetaId;
|
||||
}
|
||||
|
||||
public async Task<Result> deleteBidPriceOrder()
|
||||
{
|
||||
var result = new Result();
|
||||
string err_msg;
|
||||
|
||||
try
|
||||
{
|
||||
result = await onPrepareRequest();
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var database = getDatabase();
|
||||
|
||||
var is_success = await database.KeyDeleteAsync(getKey());
|
||||
if (false == is_success)
|
||||
{
|
||||
err_msg = $"Failed to KeyDeleteAsync() !!! : redisKey:{getKey()} - {toBasicString()}";
|
||||
Log.getLogger().debug(err_msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
err_msg = $"LandAuctionTopBidderCache deleted from Cache - redisKey:{getKey()}, {toBasicString()}";
|
||||
Log.getLogger().debug(err_msg);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var error_code = ServerErrorCode.TryCatchException;
|
||||
err_msg = $"Failed to process in deleteBidPriceOrder() !!! : errorCode{error_code}, execption:{e} - redisKey:{getKey()}, {toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> isExistKey()
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await onPrepareRequest();
|
||||
if (result.isFail()) return false;
|
||||
|
||||
var database = getDatabase();
|
||||
|
||||
var redis_value = await database.KeyExistsAsync(onMakeKey());
|
||||
return redis_value;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var error_code = ServerErrorCode.TryCatchException;
|
||||
var err_msg = $"Exception !!!, Failed to perform in LandAuctionBidPriceOrderCacheRequest.isExistKey() !!! : errorCode:{error_code}, exception:{e} - {nameof(isExistKey)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public string toKey()
|
||||
{
|
||||
return onMakeKey();
|
||||
}
|
||||
protected override string onMakeKey()
|
||||
{
|
||||
return $"{{{m_land_meta_id}}}:land_auction_bid_order";
|
||||
}
|
||||
|
||||
public string toBlockKey()
|
||||
{
|
||||
return $"{{{m_land_meta_id}}}:land_auction_bid_order_block";
|
||||
}
|
||||
|
||||
public string toKeyAll()
|
||||
{
|
||||
return $"Key:{toKey()}, BlockKey:{toBlockKey()}";
|
||||
}
|
||||
|
||||
public override string toBasicString()
|
||||
{
|
||||
return $"LandAuctionBid - LandMetaId:{m_land_meta_id}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user