UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'oKCQPGLk68Eal43stJjjd05+j514UqOLpH6H/DCirpM=' 
WHERE 
  key_id = '588f25a2fcc5705a07c3467f770dc2b9679170291707a8852e9a9c474fed6049' 
  AND (
    token = 'oKCQPGLk68Eal43stJjjd05+j514UqOLpH6H/DCirpM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00023