UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'aQr6+x5MJ0GjqsPu9KeykSsgRLNXmG6jsuyV0pHaQ1U=' 
WHERE 
  key_id = 'c49f77a173723571430b2c4710deac295967f3609d4cb472a2d29eb386248683' 
  AND (
    token = 'aQr6+x5MJ0GjqsPu9KeykSsgRLNXmG6jsuyV0pHaQ1U=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032