UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '781n4hH+0c1S4gKkJczUzqNp7sOF2cx1TWEJhPxFp+A=' 
WHERE 
  key_id = '578634b290c568835927d8767998dd8185ea03b522b1972d51a5ea47a3530d5b' 
  AND (
    token = '781n4hH+0c1S4gKkJczUzqNp7sOF2cx1TWEJhPxFp+A=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032