UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'lfEntjcKUwQQUHVpOf0CfQWMk0T/nPIPqHeP+ePoac8=' 
WHERE 
  key_id = '04eb3152755ec60df148829ec860ca5124323597ddd69d5469840535b3225320' 
  AND (
    token = 'lfEntjcKUwQQUHVpOf0CfQWMk0T/nPIPqHeP+ePoac8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037