mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
Introduce Bun.redis - a builtin Redis client for Bun (#18812)
This commit is contained in:
@@ -259,64 +259,8 @@ pub const PostgresSQLQueryResultMode = enum(u8) {
|
||||
raw = 2,
|
||||
};
|
||||
|
||||
const JSRef = union(enum) {
|
||||
weak: JSC.JSValue,
|
||||
strong: JSC.Strong,
|
||||
const JSRef = JSC.JSRef;
|
||||
|
||||
pub fn initWeak(value: JSC.JSValue) @This() {
|
||||
return .{ .weak = value };
|
||||
}
|
||||
|
||||
pub fn initStrong(value: JSC.JSValue, globalThis: *JSC.JSGlobalObject) @This() {
|
||||
return .{ .strong = JSC.Strong.create(value, globalThis) };
|
||||
}
|
||||
|
||||
pub fn empty() @This() {
|
||||
return .{ .weak = .zero };
|
||||
}
|
||||
|
||||
pub fn get(this: *@This()) JSC.JSValue {
|
||||
return switch (this.*) {
|
||||
.weak => this.weak,
|
||||
.strong => this.strong.get() orelse .zero,
|
||||
};
|
||||
}
|
||||
pub fn setWeak(this: *@This(), value: JSC.JSValue) void {
|
||||
if (this == .strong) {
|
||||
this.strong.deinit();
|
||||
}
|
||||
this.* = .{ .weak = value };
|
||||
}
|
||||
|
||||
pub fn setStrong(this: *@This(), value: JSC.JSValue, globalThis: *JSC.JSGlobalObject) void {
|
||||
if (this == .strong) {
|
||||
this.strong.set(globalThis, value);
|
||||
return;
|
||||
}
|
||||
this.* = .{ .strong = JSC.Strong.create(value, globalThis) };
|
||||
}
|
||||
|
||||
pub fn upgrade(this: *@This(), globalThis: *JSC.JSGlobalObject) void {
|
||||
switch (this.*) {
|
||||
.weak => {
|
||||
bun.assert(this.weak != .zero);
|
||||
this.* = .{ .strong = JSC.Strong.create(this.weak, globalThis) };
|
||||
},
|
||||
.strong => {},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deinit(this: *@This()) void {
|
||||
switch (this.*) {
|
||||
.weak => {
|
||||
this.weak = .zero;
|
||||
},
|
||||
.strong => {
|
||||
this.strong.deinit();
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
pub const PostgresSQLQuery = struct {
|
||||
statement: ?*PostgresSQLStatement = null,
|
||||
query: bun.String = bun.String.empty,
|
||||
|
||||
Reference in New Issue
Block a user