FreshQL

🔋 FreshQL

🚀 What is FreshQL

FreshQL is blazingly fast(at least 10x the speed of Redis) in-memory datastore and has a templating system to display the data built-in. FreshQL reflects my thoughts on building a system for building systems. Systems that deliver simplicity by delivering efficiency.

Let’s build a hello world with FreshQL:

<html>
<head>
    <title>Hello World</title>
</head>
<body>
    <h1>Hello World</h1>
</body>
</html>

Storing this on the path /hello will allow us to visit the page example.com/hello and receive the generated page.

Let’s make it personal:

<html>
<head>
    <title>Hello {{url.name}}</title>
</head>
<body>
    <h1>Hello {{url.name}}</h1>
</body>
</html>

Storing this on the path /hello/{name} allows us to tell the system to get the ‘name’ from the URL and make it available to the generating code.

Once again, we can test this by visiting example.com/hello/martin and receiving the expected greeting.

Example:

<html>
<head>
    <title>Hello {{url.name}}</title>
</head>
<body>
    <h1>Hello {{url.name}}</h1>
    {% if db.get ("last_seen:" + url.name) %}
        <p>Welcome back</p>
    {% endif %}
</body>
</html>
{% db.set current_time ("last_seen:" + url.name) %}
<h1>{{ page.title }}</h1>
<ul>
{% for post in page.posts %}
<li>
    <h3>{{ post.title }}</h3>
    <p>{{ post.text }}</p>
    <p>{{ post.author }}</p>
</li>
{% endfor %}
</ul>

And have titles and blog posts materialize automatically from the database, making the entire system self-contained.