Thursday, June 8, 2023
Dispatcher Servlet
Spring caching
<<This document is for my own reference. It helps me to remember these theories in the future. >>
First, we need to add the annotation "@EnableCaching" to the main method of the project.
The reason for using caching is to improve the system's performance. If you have saved data in the database and need to query data, you have to retrieve those values from the database each time request comes in. This could be a resource and time-consuming task. So the solution we have is, caching those data locally and passing it to the consumer if available in the local storage.
We have to be very careful when we use this caching mechanism. Because, if we update/delete one value in the table we have to use specific annotations for those methods. Otherwise, cached data doesn't update and the consumer receives incorrect data.
Follow as below when retrieving data from the database. It caches all retrieved data.
According to the above sample code, name of the cache would be "books" and key would be "id". When you trigger this method, it first checks the key is exist in the "books" cache and if available, it doesn't execute the rest of the code.
How to update a value in the cache?
When you invoke the update method, specific cached values also get updated. "@CachePut" handles this task. Unlike in the "@Cacheable" annotation, this executes the rest of the code.
How to delete a value in the cache?
"@CacheEvict" annotation takes care of removing existing cached values. If you don't use this annotation, cached values don't remove even it removed from the database.
Thursday, October 29, 2020
Generate React-Native Debug APK (Serverless)
Create an asset folder in this path
/app/src/main/
---------------------------------------------------------------------------------------------
Bundle the assets inside the assets folder created above step.
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res_
---------------------------------------------------------------------------------------------
Move to the android folder and build APK using the below command.
cd android && gradlew clean assembleDebug
---------------------------------------------------------------------------------------------
That's all! Find your debug APK inside /app/android/build/outputs/apk/debug
Tuesday, October 15, 2019
SQLite Database
SQLite
Android SQLite Java Classes
- close(): release all resources used by cursor and close it.
- getCount(): returns the number of rows contained within the result set.
- moveToFirst(): moves to the first row in the result set.
- moveToLast(): moves to the last row in the result set.
- moveToNext(): moves to the next row in the result set.
- move(): moves by a specified offset from the current position in the result set.
- get<type>() (such as getInt(), getDouble(), so on): returns the value of the specified <type> contained at the specified column index of the row at the current cursor position.
- insert(): inserts a new row into a database table.
- delete(): deletes rows from a database table
- query(): performs a specified database query and returns matching results via a Cursor object.
- execSQL(): executes a single SQL Statement that does not return result data.
- rawQuery(): executes an SQL query statement and returns matching results in the form of a Cursor object.
- onCreate(): called when the database is created for the first time.
- onUpgrade(): called in the event that the application code contains a more recent database version number reference.
- onOpen(): called when the database is opened.
- getWritableDatabase(): opens or creates a database for reading and writing.
- getReadableDatabase(): creates or opens a database for reading only.
- close(): closes the database.
- put(): adds a value to the set.
Saturday, April 23, 2016
Learn C# - Part 2
පහළින් තියෙන්නෙ if/else if/ else සේරම use කරල ලියපු statement එකක්. Try කරල බලන්න.
දැන් අපි බලමු assignment හා concatenation operation combine කරල කොහොමද statement එකක් ලියන්නෙ කියල. කලින් code එකේම අන්තිමට print කරන්න හදපු 'msg' variable එකම use කරමු.
Decision statements ලියන තවත් විදියක් ගැන අපි දැන් බලමු. මේකට conditional operator කියලත් කියනව.
මෙතනදි statement එක true නම් msg variable එකට ගන්නෙ "car" කියන string එක. false නම් පස්සෙ තියන "house" string එක msg කියන variable එකට ගන්නව. මතක තියාගන්න ඕන දේ තමයි පලවෙනි string එකට පස්සෙ දාන්න ඕනෙ colon(:) එකක් semicolon(;) එකක් නෙමෙයි.
lines කීපයක් use කරල pint කරපු message එක, තනි line එකකින් print කරගන්න පුලුවන් ලේසි විදියක් අපි දැන් බලමු. තවත් variable තියානව නම් curly braces ඇතුලෙ 3,4,5.. විදියට numbers දාල variable names අන්තිමට දාන්න පුලුවන්.
දැන් අපි බලමු Loops වැඩ කරන විදිය ගැන. මුලින් for loop කොහොමද use කරන්නෙ කියල බලමු.අනිත් languages වල වගේම තමයි වෙනසක් නෑ.
ඕනම programming language එකක වැදගත් අංගයක් තමයි arrays කියන්නෙ. අපි දැන් බලමු array එකක් කොහොමද declare කරන්නෙ කියල සහ array elements access කරන්නෙ කොහොමද කියල.
C# වල arrays index කරන්නෙ position 0 ඉඳන්.
array එකක් declare කරන තවත් ලේසි විදියක් ගැන අපි දැන් බලමු.
C# තවත් කොටසකින් නැවත හමුවෙමු
Friday, April 22, 2016
Learn C# - Part 1
C# කියන්නෙ type-safe language එකක්. ඒ කියන්නෙ C# access කරන්නෙ access කිරීමට permission තියන memory locations විතරයි. උදාහරණයක් විදියට type-safe code එකක් වෙනත් object එකක private fields read කරන්න බැහැ.type-safe code එකකට object එකක් මත operation කරන්න අවසර දෙන්නෙ නෑ එම object එකට operations අනුකුල නොවෙනව නම්. C,C++,Java වගේ languages පුරුදු අයට ලේසියෙන්ම C# ඉගෙන ගන්න පුලුවන්. අනෙක් වැදගත් කාරණය තමයි C# case sensitive language එකක්.
C# code කරන්න Visual Studio IDE එක use කරන්න පුලුවන්. මේක Microsoft එකෙන් නොමිලේ දෙන IDE එකක්.
අපි ඉතා සරල මට්ටමේ ඉඳන් C# ඉගෙන ගන්න පටන් ගමු. ඕනම language එකක වගේ Hello world program එකක් ලියල ආරම්භයක් ගමු.
අලුත් project එකක් පටන් ගන්න මේ විදියට කරන්න,
File --> New --> Project මෙතනදි එන menu එකෙන් console application තෝරගන්න. ඉස්සරහට බලමු අනිත් options වලින් මොනාද කරන්න පුලුවන් කියල. මේකෙදි output අපිට දැක ගන්න පුලුවන් වෙන්නේ Console එක හරහා.
'Start' button එක click කලාම අපිට console එකේ මේ වගේ output එකක් දැකගන්න පුලුවන්.
මේකෙදි WriteLine() method එකෙන් console එකට print කරනව, ReadLine() method එකෙන් input එකක් ලැබෙනකන් ඉන්න කියල command එකක් දෙන්නෙ.
variable declare කරන විදිය බැලුවොත් Java,C වල වගෙම variable name එකට කලින් data type එක දෙන්න තියෙන්නෙ.
eg: int x=2;
char a='i';
අපි දැන් පොඩි program එකක් ලියමු runtime එකෙදි user input දෙකක් අරගෙන ඒ දෙක concatenate කරල print කරන විදියට.
මෙතනදි WriteLine() සහ Write() විදියට method දෙකක් අපි use කරනව. ඒ දෙකේ පොඩි වෙනසක් තියෙන්නෙ. WriteLine() method එකෙන් අලුත් line එකකට යනව Write() method එකෙන් ඒ line එකේම ඉන්නව. මේ program එක run කරල input දුන්නට පස්සෙ ලැබෙන final output එක මේ විදියට දැක ගන්න පුලුවන්,
C# ඉගැනුම තවත් පාඩම් ඊළග post එකෙන් බලාපොරොත්තු වන්න..
Tuesday, August 4, 2015
IDM version 6.23 Build 18
මේකෙ Trail version එක ඕන කෙනෙක්ට download කරල භාවිත කරන්න පුලුවන් උනත් key එකක් සල්ලි දීල ගන්න ගොඩ දෙනෙක් කැමති වෙන්නෙ නෑනෙ.ඔන්න මන් ගාව තියනව හැමෝට free භවිත කරන්න පුලුවන් විදියෙ crack එක හා patch එක.
install කරන්න ඕන පිලිවෙල මුල ඉදන් කියන්නම්.
- සාමාන්ය විදියට Internet Download Manager install කරන්න.
- දැන් system tray එකෙන් IDM exit කරන්න.
- සාමාන්ය විදියට Internet Download Manager install කරන්න.
- කලින් කියපු විදියට system tray එකෙන් IDM exit කරන්න.
- Crack Folder එකේ තියන IDMan.exe එක " C:\Program Files\Internet Download Manager\ එකට Copy - Paste කරන්න.
- ඊලගට IDM Reg Key.reg කියන එක Doubble click කරලා IDM එක Register කරගන්න.