배우기
엔진 클래스
MemoryStoreSortedMap
만들 수 없음
복제되지 않음

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.


요약
메서드
GetRangeAsync(direction: Enum.SortDirection,count: number,exclusiveLowerBound: Variant,exclusiveUpperBound: Variant):{any}
SetAsync(key: string,value: Variant,expiration: number,sortKey: Variant):boolean
UpdateAsync(key: string,transformFunction: function,expiration: number):Tuple
상속된 멤버

API 참조
메서드
GetAsync
생성
기능: DataStore
MemoryStoreSortedMap:GetAsync(key:string):Tuple
매개 변수
key:string
반환

GetRangeAsync
생성
기능: DataStore
MemoryStoreSortedMap:GetRangeAsync(
direction:Enum.SortDirection, count:number, exclusiveLowerBound:Variant, exclusiveUpperBound:Variant
매개 변수
count:number
exclusiveLowerBound:Variant
exclusiveUpperBound:Variant
반환
코드 샘플
메모리 저장소 키 가져오기
local MemoryStoreService = game:GetService("MemoryStoreService")
local myMap = MemoryStoreService:GetSortedMap("MySortedMap")
function printAllKeys(map)
-- 초기 하한선은 nil이며, 이는 첫 번째 항목부터 시작함을 의미합니다.
local exclusiveLowerBound = nil
-- 이 루프는 맵의 끝에 도달할 때까지 계속됩니다.
while true do
-- 현재 하한선에서 시작하여 최대 100개의 항목을 가져옵니다.
local items = map:GetRangeAsync(Enum.SortDirection.Ascending, 100, exclusiveLowerBound)
for _, item in ipairs(items) do
print(item.key)
print(item.sortKey)
end
-- 호출에 의해 100개 미만의 항목이 반환되면, 맵의 끝에 도달한 것입니다.
if #items < 100 then
break
end
-- 마지막으로 검색한 키는 다음 반복의 배타적 하한선입니다.
exclusiveLowerBound = {}
exclusiveLowerBound["key"] = items[#items].key
exclusiveLowerBound["sortKey"] = items[#items].sortKey
end
end
printAllKeys(myMap)

GetSizeAsync
생성
기능: DataStore
MemoryStoreSortedMap:GetSizeAsync():number
반환

RemoveAsync
생성
기능: DataStore
MemoryStoreSortedMap:RemoveAsync(key:string):()
매개 변수
key:string
반환
()

SetAsync
생성
기능: DataStore
MemoryStoreSortedMap:SetAsync(
key:string, value:Variant, expiration:number, sortKey:Variant
매개 변수
key:string
value:Variant
expiration:number
sortKey:Variant
반환

UpdateAsync
생성
기능: DataStore
MemoryStoreSortedMap:UpdateAsync(
key:string, transformFunction:function, expiration:number
매개 변수
key:string
transformFunction:function
expiration:number
반환
코드 샘플
메모리 스토어 정렬 맵 업데이트
local MemoryStoreService = game:GetService("MemoryStoreService")
local map = MemoryStoreService:GetSortedMap("Leaderboard")
local Players = game:GetService("Players")
function updateLeaderboard(itemKey, killsToAdd, deathsToAdd)
local success, newStats, newScore = pcall(function()
return map:UpdateAsync(itemKey, function(playerStats, playerScore)
playerStats = playerStats or { kills = 0, deaths = 0 }
playerStats.kills += killsToAdd
playerStats.deaths += deathsToAdd
if playerStats then
-- `playerScore`는 맵에서 항목을 정렬하는 데 사용되는 sortKey입니다.
playerScore = playerStats.kills / math.max(playerStats.deaths, 1)
return playerStats, playerScore
end
return nil
end, 30)
end)
end
-- 모든 플레이어에게 처치 1 추가
for i, player in pairs(Players:GetPlayers()) do
updateLeaderboard(player.UserId, 1, 0)
end
-- userId 12345인 플레이어에게 처치 5 및 사망 1 추가
updateLeaderboard(12345, 5, 1)

©2026 Roblox Corporation. Roblox 및 Roblox 로고, 'Powering Imagination'은 미국 및 기타 국가 내 당사의 등록 및 미등록 상표입니다.