Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Allows Components to be written into memory for faster serving.

License

Notifications You must be signed in to change notification settings

ChifiSource/ToolipsMemWrite.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dead repo

ToolipsMemWrite is deprecated in favor of easier extension loading and Component composure.

  • ( This project can still be used with Toolips 0.2. )
  • Documentation
  • Toolips
  • Extension Gallery
    Writes Components into memory and can also save serialized Component Vectors automatically. Writing to memory is done with the memwrite! function. This function can also be used inside of a conditional.
using Toolips
using ToolipsMemWrite

function myroute(c::Connection)
    mycomp = divider("mydivider", align = "center")
    myp = p("myp", text = "hello world!")
    push!(mycomp, myp)
    othercomp = a("othercomp", text = "othercomp")
    # Saved:
    memwrite!(c, mycomp)
    # Not saved:
    write!(c, othercomp)
end

st = ServerTemplate(extensions = [Logger(), ComponentMemory()])
st.start()

This approach is alright, but still puts CPU power towards writing the Components. It is way better to instead use memwrite! with write set to false first, then use memwrite! normally. You can follow this with a return, which breaks the function pipeline and ceases the writing of the function.

using Toolips
using ToolipsMemWrite

function myroute(c::Connection)
    if memwrite!(c, "mydivider", write = false)
        memwrite!(c, "mydivider")
        return
    end
    mycomp = divider("mydivider", align = "center")
    myp = p("myp", text = "hello world!")
    push!(mycomp, myp)
    othercomp = a("othercomp", text = "othercomp")
    memwrite!(c, mycomp)
end

st = ServerTemplate(extensions = [Logger(), ComponentMemory()])
st.start()

You can also use the same techniques with diskwrite!.

using Toolips
using ToolipsMemWrite

function myroute(c::Connection)
    if diskwrite!(c, "mydivider", write = false)
        diskwrite!(c, "mydivider")
        return
    end
    mycomp = divider("mydivider", align = "center")
    myp = p("myp", text = "hello world!")
    push!(mycomp, myp)
    othercomp = a("othercomp", text = "othercomp")
    diskwrite!(c, mycomp)
end

st = ServerTemplate(extensions = [Logger(), ComponentMemory()])
st.start()

About

Allows Components to be written into memory for faster serving.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages