Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
coreospackage
Commits
be4381e1
Commit
be4381e1
authored
7 years ago
by
Sandeep S. Shewalkar
Browse files
Options
Downloads
Patches
Plain Diff
Lazy writer
ForceSaveDataToFDB method commented
parent
133b956b
Branches
Branches containing commit
1 merge request
!25
Lazy writer
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dalhelper/lazywriter.go
+0
-49
dalhelper/lazywriter.go
with
0 additions
and
49 deletions
dalhelper/lazywriter.go
+
0
−
49
View file @
be4381e1
package
dalhelper
import
(
"encoding/json"
"sync"
"time"
...
...
@@ -302,53 +300,6 @@ func (lfd *LazyFDPHelper) PurgeCache() {
lazyMutex
.
Unlock
()
}
// ForceSaveDataToFDB this method saves data to fdb forcefully and put the object inside cache
func
(
lfd
*
LazyFDPHelper
)
ForceSaveDataToFDB
(
identifier
string
)
{
// Fetch All Rows and then save into db
cachedObjectList
:=
lfd
.
gc
.
GetALL
()
for
item
:=
range
cachedObjectList
{
//TODO: catch errors
cachedObject
,
getError
:=
lfd
.
gc
.
Get
(
item
)
if
getError
!=
nil
{
logginghelper
.
LogError
(
"error occured while getting "
,
item
,
" from gcache"
)
}
cachedObjectActual
,
_
:=
cachedObject
.
(
LazyCacheObject
)
if
cachedObjectActual
.
Identifier
==
identifier
{
cachedObjectActual
.
IsLocked
=
true
saveDataToFDB
(
cachedObjectActual
.
FileName
,
cachedObjectActual
.
InterfaceData
)
cachedObjectActual
.
ChangeCount
=
0
cachedObjectActual
.
IsLocked
=
false
lazyMutex
.
Lock
()
lfd
.
DISK_WRITE_COUNT
++
lazyMutex
.
Unlock
()
// get data from data base and it inside cache
dataFromFdb
,
getError
:=
GetDataFromFDB
(
cachedObjectActual
.
FileName
)
if
getError
!=
nil
{
logginghelper
.
LogError
(
"error occured while fetching data from database for file : "
,
cachedObjectActual
.
FileName
,
getError
)
// in case of error, i.e. if data fetching failed, remove key from cache
lfd
.
gc
.
Remove
(
cachedObjectActual
.
FileName
)
}
else
{
var
interfaceData
interface
{}
unmarshalError
:=
json
.
Unmarshal
(
dataFromFdb
,
&
interfaceData
)
if
unmarshalError
!=
nil
{
logginghelper
.
LogError
(
"error occured while unmarshalling data of file : "
,
cachedObjectActual
.
FileName
,
unmarshalError
)
lfd
.
gc
.
Set
(
cachedObjectActual
.
FileName
,
cachedObjectActual
)
}
else
{
cachedObjectActual
.
InterfaceData
=
interfaceData
lfd
.
gc
.
Set
(
cachedObjectActual
.
FileName
,
cachedObjectActual
)
}
}
}
}
}
// =================================== > Lazywriter for appending data to file < ============================================
// StartProcessForAppend StartProcessForAppend
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets