Skip to content

Commit

Permalink
improve md
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Jun 6, 2024
1 parent 69f0a85 commit 66dba7c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 29 deletions.
8 changes: 4 additions & 4 deletions docs/recipes/startup-listeners-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
]
}
-->
## Startup Listeners Code ##
# Startup Listeners, server.cfc and web.cfc

Lucee has two kinds of startup listeners.

- **Server.cfc** which runs when the Lucee Server starts up. It exists only once per Lucee instance.
- **Web.cfc** which can be used for each web context.

### Server.cfc ###
## Server.cfc

Create a `Server.cfc` file in `lucee-server\context\context` directory.

Expand Down Expand Up @@ -59,7 +59,7 @@ component{
- Start Lucee Server.
- The server console or `out.log` should show the above systemOutput's which means it has run the `Server.cfc`

### Web.cfc ###
## Web.cfc

Create a `Web.cfc` file in `webapps\ROOT\WEB-INF\lucee\context\` directory, or the context webroot.

Expand Down Expand Up @@ -98,7 +98,7 @@ Here ``reload`` is used to reload the web context. We see the difference when se

This is a simple way to stop the server context. It is never triggered because there is no event happening inside java.

### Footnotes ###
## Footnotes

Here you can see above details in video

Expand Down
16 changes: 8 additions & 8 deletions docs/recipes/static_scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
]
}
-->
## Static scope in components
# Static scope in components

Static scope in components is needed to create an instance of cfc and call its method. It is used to avoid creating an instance each time you use the cfc.

You can create an object in the Application init() function, and make it at application scope, so you can directly call the methods.

We explain this methodology with a simple example below:

### Example:
## Example 1

```luceescript
// index.cfm
Expand Down Expand Up @@ -61,7 +61,7 @@ cfc = new Example0();
cfc.hey();
```

### Example 1:
## Example 2

As our code gets more complicated, we need to make some additions to it.

Expand Down Expand Up @@ -96,7 +96,7 @@ new Example1();
new Example1();
```

### Example 2:
## Example 3

1) Another example is using the static scope to store the result of a time-consuming operation that does not need to be recomputed every time.

Expand Down Expand Up @@ -125,7 +125,7 @@ new Example2();
new Example2();
```

### Example 3:
## Example 4

1) The static scope can also be used for functions. In this example, we define a static function that is available to all instances.

Expand All @@ -145,7 +145,7 @@ Component {
dump(Example3::hello());
```

### Example 4:
## Example 5

1) The static scope can be used to count the number of instances created from a component.

Expand All @@ -171,7 +171,7 @@ new Example4();
new Example4();
```

### Example 5:
## Example 6

1) We can also use the static scope to store constant data like HOST, PORT.

Expand Down Expand Up @@ -207,7 +207,7 @@ dump(person.getLastName());
dump(Example5::splitFullName("Quintana Jesus"));
```

### Footnotes
## Footnotes

[Lucee 5 features reviewed: static](https://dev.lucee.org/t/lucee-5-features-reviewed-static/433)

Expand Down
8 changes: 4 additions & 4 deletions docs/recipes/supercharge-your-website.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
]
}
-->
## Supercharge your website ##
# Supercharge your website

This document explains how you can improve the performance of your website in a very short time with Lucee.

### Example: ###
## Example:

```luceescript
// index.cfm
Expand All @@ -25,7 +25,7 @@ writeDump(now());

Run the above index.cfm, and you get a timestamp. Whenever we call our file, Lucee checks once at every request if a file has changed or not (for files currently residing in the template cache). If a file has changed, Lucee recompiles it, and executes it. Checking the files at every request takes time. If you have a published server, and you know your server does not produce or change any files, you can simply avoid that check that happens all the time.

### Using Admin ###
## Using Admin

* Go to _Admin -> Performance/ Caching -> Inspect Templates (CFM/CFC) -> Never_

Expand All @@ -37,7 +37,7 @@ Run the above index.cfm, and you get a timestamp. Whenever we call our file, Luc

* Another option to clear the template cache is to use clear cache via the admin by clicking the button in _Admin -> Settings -> Performance/ Caching -> Page Pool Cache_.

### Footnotes ###
## Footnotes

Here you can see these details on video also:

Expand Down
12 changes: 6 additions & 6 deletions docs/recipes/thread_task.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
]
}
-->
## Thread Task ##
# Thread Task

This document explains about the thread tasks. It is useful to know the differences between regular threads and task threads.

Expand All @@ -32,7 +32,7 @@ Regular Threads have the following characteristics:

3) **It fails when it fails**: There is no special exception handling so when the thread fails it fails unless you have Cftry, cfcatch inside the thread and you have exception handling there.

### Example 1: ###
## Example 1

In addition to daemon (regular) threads, Lucee also supports task threads. The main differences is that task threads execute completely independently of the request that is calling the thread. We log the thread and can re-execute it.

Expand All @@ -50,7 +50,7 @@ Note that when you execute the example code, you will get no output. This is exp

However, view the Lucee _Admin --> Services --> Tasks_ and see the name of the tasks and their `Type` is `daemon` and the status is `terminated`.

### Example 2: ###
## Example 2

Next we show a similar example using the task type:

Expand All @@ -64,7 +64,7 @@ dump(getPageContext().getTasks().getTask("test"));

This example shows the task type. This example is similar to the daemon thread. It waits 1 second before outputting the task details. The task type thread will continue to run independently.

### Example 3: ###
## Example 3

Task threads can be retried multiple times if they fail. This is different from daemon threads which fail permanently after an exception. Below example shows a task thread that retries multiple times.

Expand All @@ -85,7 +85,7 @@ dump(getPageContext().getTasks().getTask("test"));

This example creates a task thread named `test` that retries according to the defined intervals. Initially, the task thread throws an exception. The retry intervals are defined in the array with `tries` and `interval` attributes.

### Example 4: ###
## Example 4

Another example for getting the admin component and task is physically created on the system.

Expand Down Expand Up @@ -115,7 +115,7 @@ admin.removeAllTask();

3) `admin.removeTask()` and `admin.removeAllTask()` are used to remove tasks from the administrator.

### Footnotes ###
## Footnotes

Here you can see the details in the video:
[Thread Task](https://youtu.be/-SUbVWqJRME)
12 changes: 6 additions & 6 deletions docs/recipes/thread_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
]
}
-->
## Thread Scope
# Thread Scope

This document explains how to use threads in Lucee. Threads are mainly used for executing code in parallel.

### Example 1
## Example 1

The below example shows normal execution, waiting for all code to resolve. Here it takes 1000 milliseconds to complete the execution.

Expand Down Expand Up @@ -54,7 +54,7 @@ Threads run independently of other threads or code in Lucee. Lucee does not the

Threads are mainly used to retrieve data from the database, cfhttp, or webservice. Threads are used when it does not matter how much time it takes to execute.

### Example 2
## Example 2

Here we see an example using multiple threads in Lucee. All threads run in parallel.

Expand Down Expand Up @@ -86,7 +86,7 @@ dump("done in #getTickCount()-start#ms");

The above example shows five threads running in parallel. The thread action="join" line waits for all threads to finish. `cfthread` returns struct info of all thread statuses.

### Example 3
## Example 3

Threads can also be used to perform long-running tasks asynchronously.

Expand Down Expand Up @@ -138,7 +138,7 @@ dump("done");
</cfscript>
```

### Example 4
## Example 4

Lucee members often discuss how to extend functionality to make Lucee easier to use or adding other new functionality.

Expand Down Expand Up @@ -185,7 +185,7 @@ for(i=0; i<10; i++; true) {

Another planned enhancement is to extend parallel to the loop by simply adding `parallel=true`. It will execute the body of the loop in parallel.

### Footnotes
## Footnotes

Here you can see the above details in a video:

Expand Down
4 changes: 3 additions & 1 deletion docs/recipes/xml_fast-easy.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
]
}
-->
# XML Fast And Easy, using SAX - Listener Functions

This document explains how to use XML parsing in Lucee.

I have XML as shown below:
Expand Down Expand Up @@ -423,7 +425,7 @@ The example above executes and returns a result array which contains only the ye

You can modify the component as you like. Instead of storing the array, you can store the result in a database or mail, or whatever you like.

### Footnotes ###
## Footnotes

You can see the details in this video:
[Xml-Fast and Easy](https://www.youtube.com/watch?v=_AP6GpVk7TE)

0 comments on commit 66dba7c

Please sign in to comment.