Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 37 additions & 6 deletions src/cfc/cfredis.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ Thanks!


<!--- AUTH - String auth(String password) --->
<!--- It's advised to set server password when creating the JedisPool instance rather than using AUTH --->
<cffunction name="auth" access="public" returntype="string" output="no">
<cfargument name="password" type="string" required="yes" />

Expand Down Expand Up @@ -527,14 +526,14 @@ Thanks!


<!--- GET - String get(String key) --->
<cffunction name="get" access="public" returntype="string" output="no">
<cffunction name="get" access="public" returntype="any" output="no">
<cfargument name="key" type="string" required="yes" />

<cfset var connection = '' />
<cfset var result = '' />

<cfset connection = getResource() />
<cfset result = connection.get(JavaCast("string", arguments.key)) />
<cfset result = this.deserialize( connection.get(JavaCast("string", arguments.key)) )/>
<cfset returnResource(connection) />

<cfif isDefined("result")>
Expand Down Expand Up @@ -1833,16 +1832,16 @@ Thanks!
</cffunction>


<!--- SET - String set(String key, String value) --->
<!--- SET - String set(String key, value) --->
<cffunction name="set" access="public" returntype="string" output="no">
<cfargument name="key" type="string" required="yes" />
<cfargument name="value" type="string" required="yes" />
<cfargument name="value" type="any" required="yes" />

<cfset var connection = '' />
<cfset var result = '' />

<cfset connection = getResource() />
<cfset result = connection.set(JavaCast("string", arguments.key), JavaCast("string", arguments.value)) />
<cfset result = connection.set(JavaCast("string", arguments.key), JavaCast("string", this.serialize(arguments.value))) />
<cfset returnResource(connection) />

<cfif isDefined("result")>
Expand Down Expand Up @@ -2964,4 +2963,36 @@ Thanks!
</cfif>
</cffunction>




<cffunction name="serialize" access="package" output="false" returntype="any"
hint="Serializes the given value from a byte stream.">
<cfargument name="value" required="true" />
<cfscript>
var ret = "";
if (isSimpleValue(arguments.value)) {
ret = arguments.value;
} else {
ret = "ENC~" & toBase64( objectSave(arguments.value) );
}
</cfscript>
<cfreturn ret>
</cffunction>

<cffunction name="deserialize" access="package" output="false" returntype="any"
hint="Deserializes the given value from a byte stream. this works with multiple keys being returned" >
<cfargument name="value" required="true" type="any" default="" />

<cfif isSimpleValue(arguments.value) AND left( arguments.value, 4 ) IS "ENC~">
<cfreturn objectLoad( toBinary( right( arguments.value, len(arguments.value)-4 ) ) )>
</cfif>

<cfreturn arguments.value />
</cffunction>





</cfcomponent>