Skip to content

Instantly share code, notes, and snippets.

@itang
Created July 20, 2021 04:03
Show Gist options
  • Save itang/6b16a09d62b24ab32698b1ed8a803515 to your computer and use it in GitHub Desktop.
Save itang/6b16a09d62b24ab32698b1ed8a803515 to your computer and use it in GitHub Desktop.
open System
open FreeRedis
// Define a function to construct a message to print
let from whom = sprintf "from %s" whom
let inline (|>!) x sideEffect =
do sideEffect x
x
module Redis =
let get key (client: RedisClient) = client.Get(key)
let set key value (client: RedisClient) = client.Set(key, value)
[<EntryPoint>]
let main argv =
let cli =
"127.0.0.1:6379,password=foobared,defaultDatabase=0"
|> ConnectionStringBuilder.Parse
|> (fun c -> new RedisClient(c))
cli.Set("foo", 100)
let value : string = cli.Get("foo")
printfn "%s" value
printfn "%A" (cli.Get("foo"))
cli
|> (fun x ->
x |> Redis.set "name" "itang"
x)
|> Redis.get "name"
|> printfn "name: %s"
cli |>! Redis.set "name" "tqibm"
|> Redis.get "name"
|> printfn "%s"
cli.Dispose()
0 // return an integer exit code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment