UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'i0CmDlNQmHFqWPekNRcCXZf77F6mW35YhW+Azhefg38='
WHERE
key_id = 'e4f1ce9ea87e24560df4ed686ab874bd364f6ce45e8dc235a0e131c19c66881f'
AND (
token = 'i0CmDlNQmHFqWPekNRcCXZf77F6mW35YhW+Azhefg38='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)