// Create a new list. // id is the name of the list. // dbindex is the Redis database index (typically 0). func newList(L *lua.LState, creator pinterface.ICreator, id string) (*lua.LUserData, error) { // Create a new list list, err := creator.NewList(id) if err != nil { return nil, err } // Create a new userdata struct ud := L.NewUserData() ud.Value = list L.SetMetatable(ud, L.GetTypeMetatable(lListClass)) return ud, nil }
// Create a new code library. // id is the name of the hash map. func newCodeLibrary(L *lua.LState, creator pinterface.ICreator, id string) (*lua.LUserData, error) { // Create a new Lua Library (hash map) lualib, err := creator.NewKeyValue(id) if err != nil { return nil, err } // Create a new userdata struct ud := L.NewUserData() ud.Value = lualib L.SetMetatable(ud, L.GetTypeMetatable(lLibraryClass)) return ud, nil }
// Create a new KeyValue collection. // id is the name of the KeyValue colleciton. // dbindex is the Redis database index (typically 0). func newKeyValue(L *lua.LState, creator pinterface.ICreator, id string) (*lua.LUserData, error) { // Create a new key/value kv, err := creator.NewKeyValue(id) if err != nil { return nil, err } // Create a new userdata struct ud := L.NewUserData() ud.Value = kv L.SetMetatable(ud, L.GetTypeMetatable(lKeyValueClass)) return ud, nil }
// Create a new hash map. // id is the name of the hash map. // dbindex is the Redis database index (typically 0). func newHashMap(L *lua.LState, creator pinterface.ICreator, id string) (*lua.LUserData, error) { // Create a new hash map hash, err := creator.NewHashMap(id) if err != nil { return nil, err } // Create a new userdata struct ud := L.NewUserData() ud.Value = hash L.SetMetatable(ud, L.GetTypeMetatable(lHashClass)) return ud, nil }