UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'HLbYQb7CCGLyPzCs3d6wbwa8dTKAW25A0DV85kHRT50='
WHERE
key_id = 'a4b7fe9784909b74a71b17ae960250177a05d62b8cbf24338a792fa44a008b3e'
AND (
token = 'HLbYQb7CCGLyPzCs3d6wbwa8dTKAW25A0DV85kHRT50='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)