|
Hibernate already has support for query cache. And we know that when we perform a big task there are huge number queries remain in our cache factory. And more important that in most cases we don't need this caches so as a result cache factory getting full with unusual cache data.
This could be a performance issue - so it's better we clear cache on our own responsibility after a big task completed. |
| Below are the procedure to flush and clear current session (hibernate session) data so that cache factory have enough space for further execution. |
import org.hibernate.SessionFactory import grails.util.Holders private static SessionFactory _sessionFactory static Boolean flushAndClearCache() { try { sessionFactory.currentSession.flush() sessionFactory.currentSession.clear() sessionFactory.getCache().evictEntityRegions() sessionFactory.getCache().evictCollectionRegions() sessionFactory.getCache().evictDefaultQueryRegion() sessionFactory.getCache().evictQueryRegions() return true } catch (Throwable ex) { log.error(ex.ex) return false } } static <T> T getBean(Class<T> requiredType) { try { return Holders.applicationContext.getBean(requiredType) } catch (Throwable e) { return null } } static SessionFactory getSessionFactory() { _sessionFactory = _sessionFactory ?: (_sessionFactory = getBean(SessionFactory)) } |
Showing posts with label Clear Cache. Show all posts
Showing posts with label Clear Cache. Show all posts
Sunday, October 18, 2020
Grails on Groovy - Clear and Flush Current Hibernate Session Data and Evict All Query Cache Data | Clearing Hibernate Query Cache in Grails
Saturday, February 4, 2017
Windows CMD, Clear All Browsers Cache & Everything
::@ECHO OFF
::cscript.exe "Test.vbs"
::pause
::exit;
@echo off
rem IE
taskkill /F /IM iexplore.exe
start "" "C:\Windows\System32\rundll32.exe" InetCpl.cpl,ClearMyTracksByProcess 255
:: Parse the Local AppData sub path
call :Expand xAppData "%%LocalAppData:%UserProfile%=%%"
set "xFirefox=\mozilla\firefox\profiles"
set "xChrome=\google\chrome\user data"
set "xOpera1=\Local\Opera\Opera"
set "xOpera2=\Roaming\Opera\Opera"
:: Start at the User directory
pushd "%UserProfile%\.."
taskkill /F /IM firefox.exe
taskkill /F /IM chrome.exe
taskkill /F /IM opera.exe
:: Loop through the Users
for /D %%D in (*) do if exist "%%~fD%xAppData%" (
rem Check for Firefox
if exist "%%~fD%xAppData%%xFirefox%" (
rd /s /q "%%~fD%xAppData%%xFirefox%"
)
rem Check for Chrome
if exist "%%~fD%xAppData%%xChrome%" (
rd /s /q "%%~fD%xAppData%%xChrome%"
)
rem Check for Opera
if exist "%%~fD%xAppData%%xOpera1%" (
rd /s /q "%%~fD%xAppData%%xOpera1%"
)
if exist "%%~fD%xAppData%%xOpera2%" (
rd /s /q "%%~fD%xAppData%%xOpera2%"
)
)
popd
goto End
::::::::::::::::::::::::::::::
:Expand <Variable> <Value>
if not "%~1"=="" set "%~1=%~2"
goto :eof
:End
endlocal
VBScript Clear Google Chrome Cache, History & Everything
Option Explicit
Dim FileSystemObject, RootFolder, UserName, File
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
UserName = CreateObject("WScript.Network").UserName
RootFolder = "C:\Users\" & UserName & "\AppData\Local\Google\Chrome\User Data\"
ProcessTerminate "chrome.exe"
DeleteFileFromFolder RootFolder
Sub DeleteFileFromFolder(Path)
For Each File In FileSystemObject.GetFolder(Path).Files
DeleteAllow File
Next
For Each File In FileSystemObject.GetFolder(Path).SubFolders
DeleteFileFromFolder File.Path
Next
End Sub
Sub DeleteAllow(File)
'Bookmarks remain same
If NOT(StrComp(Left(File.Name, 9), "Bookmarks", vbTextCompare)) = 0 Then
Wscript.Echo File.Path + " Deleted"
On Error Resume Next
FileSystemObject.DeleteFile File.Path, True
End If
End Sub
Sub ProcessTerminate(Process)
Const StrComputer = "."
Dim WshShell, ObjWMIService, ProcessList, ObjProcess
Set WshShell = CreateObject("WScript.Shell")
Set ObjWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & StrComputer & "\root\cimv2")
Set ProcessList = ObjWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = '" & Process & "'")
For Each ObjProcess in ProcessList
On Error Resume Next
ObjProcess.Terminate
Wscript.Echo "Process Terminated, ProcessId=" & ObjProcess.ProcessId & " (" & ObjProcess.Name & ")"
Next
End Sub
Friday, December 2, 2016
Subscribe to:
Comments (Atom)
